event.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package models
  2. import (
  3. "gorm.io/gorm"
  4. )
  5. type EventStatus int64
  6. const (
  7. EventStatusSuccess EventStatus = 1
  8. EventStatusInProgress = 2
  9. EventStatusFailed = 3
  10. )
  11. type EventContainer struct {
  12. gorm.Model
  13. ReleaseID uint
  14. Steps []SubEvent
  15. }
  16. type SubEvent struct {
  17. gorm.Model
  18. EventContainerID uint
  19. EventID string // events with the same id wil be treated the same, and the highest index one is retained
  20. Name string
  21. Index int64 // priority of the event, used for sorting
  22. Status EventStatus
  23. Info string
  24. }
  25. type SubEventExternal struct {
  26. EventID string `json:"event_id"`
  27. Name string `json:"name"`
  28. Index int64 `json:"index"`
  29. Status EventStatus `json:"status"`
  30. Info string `json:"info"`
  31. Time int64 `json:"time""`
  32. }
  33. func (event *SubEvent) Externalize() SubEventExternal {
  34. return SubEventExternal{
  35. EventID: event.EventID,
  36. Name: event.Name,
  37. Index: event.Index,
  38. Status: event.Status,
  39. Info: event.Info,
  40. Time: event.UpdatedAt.Unix(),
  41. }
  42. }