release.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "github.com/porter-dev/porter/api/types"
  4. "gorm.io/gorm"
  5. )
  6. // Release model used to retrieve webhook tokens for a chart.
  7. // Release type that extends gorm.Model
  8. type Release struct {
  9. gorm.Model
  10. WebhookToken string `json:"webhook_token" gorm:"unique"`
  11. ClusterID uint `json:"cluster_id"`
  12. ProjectID uint `json:"project_id"`
  13. Name string `json:"name"`
  14. Namespace string `json:"namespace"`
  15. // The complete image repository uri to pull from. This is also stored in GitActionConfig,
  16. // but this should be used for the source of truth going forward.
  17. ImageRepoURI string `json:"image_repo_uri,omitempty"`
  18. GitActionConfig *GitActionConfig `json:"git_action_config"`
  19. EventContainer uint
  20. NotificationConfig uint
  21. BuildConfig uint
  22. Tags []Tag `json:"tags" gorm:"many2many:release_tags"`
  23. }
  24. func (r *Release) ToReleaseType() *types.PorterRelease {
  25. res := &types.PorterRelease{
  26. ID: r.ID,
  27. WebhookToken: r.WebhookToken,
  28. ImageRepoURI: r.ImageRepoURI,
  29. }
  30. if r.GitActionConfig != nil {
  31. res.GitActionConfig = r.GitActionConfig.ToGitActionConfigType()
  32. }
  33. return res
  34. }