release.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package models
  2. import (
  3. "gorm.io/gorm"
  4. )
  5. // Release model used to retrieve webhook tokens for a chart.
  6. // Release type that extends gorm.Model
  7. type Release struct {
  8. gorm.Model
  9. WebhookToken string `json:"webhook_token" gorm:"unique"`
  10. ClusterID uint `json:"cluster_id"`
  11. ProjectID uint `json:"project_id"`
  12. Name string `json:"name"`
  13. Namespace string `json:"namespace"`
  14. // The complete image repository uri to pull from. This is also stored in GitActionConfig,
  15. // but this should be used for the source of truth going forward.
  16. ImageRepoURI string `json:"image_repo_uri,omitempty"`
  17. GitActionConfig GitActionConfig `json:"git_action_config"`
  18. NotificationConfig uint
  19. }
  20. // ReleaseExternal represents the Release type that is sent over REST
  21. type ReleaseExternal struct {
  22. ID uint `json:"id"`
  23. WebhookToken string `json:"webhook_token"`
  24. GitActionConfig *GitActionConfigExternal `json:"git_action_config,omitempty"`
  25. }
  26. // Externalize generates an external User to be shared over REST
  27. func (r *Release) Externalize() *ReleaseExternal {
  28. return &ReleaseExternal{
  29. ID: r.ID,
  30. WebhookToken: r.WebhookToken,
  31. GitActionConfig: r.GitActionConfig.Externalize(),
  32. }
  33. }