release.go 1.0 KB

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