release.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. EventContainer uint
  19. NotificationConfig uint
  20. }
  21. // ReleaseExternal represents the Release type that is sent over REST
  22. type ReleaseExternal struct {
  23. ID uint `json:"id"`
  24. WebhookToken string `json:"webhook_token"`
  25. GitActionConfig *GitActionConfigExternal `json:"git_action_config,omitempty"`
  26. }
  27. // Externalize generates an external User to be shared over REST
  28. func (r *Release) Externalize() *ReleaseExternal {
  29. return &ReleaseExternal{
  30. ID: r.ID,
  31. WebhookToken: r.WebhookToken,
  32. GitActionConfig: r.GitActionConfig.Externalize(),
  33. }
  34. }