release.go 1.2 KB

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