helm_repo.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "github.com/porter-dev/porter/api/types"
  4. "github.com/porter-dev/porter/internal/models/integrations"
  5. "gorm.io/gorm"
  6. )
  7. // HelmRepo is an integration that can connect to a Helm repository via a
  8. // set of auth mechanisms
  9. type HelmRepo struct {
  10. gorm.Model
  11. // Name given to the Helm repository
  12. Name string `json:"name"`
  13. // The project that this integration belongs to
  14. ProjectID uint `json:"project_id"`
  15. // RepoURL is the URL to the helm repo. This varies based on the integration
  16. // type. For example, for AWS S3 this may be prefixed with s3://, or for
  17. // GCS it may be gs://
  18. RepoURL string `json:"repo_url"`
  19. // ------------------------------------------------------------------
  20. // All fields below this line are encrypted before storage
  21. // ------------------------------------------------------------------
  22. BasicAuthIntegrationID uint
  23. GCPIntegrationID uint
  24. AWSIntegrationID uint
  25. // A token cache that can be used by an auth mechanism (integration), if desired
  26. TokenCache integrations.HelmRepoTokenCache
  27. }
  28. // HelmRepoExternal is an external HelmRepo to be shared over REST
  29. type HelmRepoExternal struct {
  30. ID uint `json:"id"`
  31. // The project that this integration belongs to
  32. ProjectID uint `json:"project_id"`
  33. // Name of the repo
  34. Name string `json:"name"`
  35. RepoURL string `json:"repo_name"`
  36. }
  37. // ToHelmRepoType generates an external HelmRepo to be shared over REST
  38. func (hr *HelmRepo) ToHelmRepoType() *types.HelmRepo {
  39. return &types.HelmRepo{
  40. ID: hr.ID,
  41. ProjectID: hr.ProjectID,
  42. Name: hr.Name,
  43. RepoURL: hr.RepoURL,
  44. }
  45. }