project.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package models
  2. import (
  3. "gorm.io/gorm"
  4. "github.com/porter-dev/porter/api/types"
  5. ints "github.com/porter-dev/porter/internal/models/integrations"
  6. )
  7. type ProjectPlan string
  8. const (
  9. ProjectPlanBasic ProjectPlan = "basic"
  10. ProjectPlanTeam ProjectPlan = "team"
  11. ProjectPlanGrowth ProjectPlan = "growth"
  12. ProjectPlanEnterprise ProjectPlan = "enterprise"
  13. )
  14. // Project type that extends gorm.Model
  15. type Project struct {
  16. gorm.Model
  17. Name string `json:"name"`
  18. Roles []Role `json:"roles"`
  19. ProjectUsageID uint
  20. ProjectUsageCacheID uint
  21. // linked repos
  22. GitRepos []GitRepo `json:"git_repos,omitempty"`
  23. // linked registries
  24. Registries []Registry `json:"registries,omitempty"`
  25. // linked clusters
  26. Clusters []Cluster `json:"clusters"`
  27. ClusterCandidates []ClusterCandidate `json:"cluster_candidates"`
  28. // linked helm repos
  29. HelmRepos []HelmRepo `json:"helm_repos"`
  30. // invitations to the project
  31. Invites []Invite `json:"invites"`
  32. // provisioned aws infra
  33. Infras []Infra `json:"infras"`
  34. // auth mechanisms
  35. KubeIntegrations []ints.KubeIntegration `json:"kube_integrations"`
  36. BasicIntegrations []ints.BasicIntegration `json:"basic_integrations"`
  37. OIDCIntegrations []ints.OIDCIntegration `json:"oidc_integrations"`
  38. OAuthIntegrations []ints.OAuthIntegration `json:"oauth_integrations"`
  39. AWSIntegrations []ints.AWSIntegration `json:"aws_integrations"`
  40. GCPIntegrations []ints.GCPIntegration `json:"gcp_integrations"`
  41. }
  42. // ToProjectType generates an external types.Project to be shared over REST
  43. func (p *Project) ToProjectType() *types.Project {
  44. roles := make([]*types.Role, 0)
  45. for _, role := range p.Roles {
  46. roles = append(roles, role.ToRoleType())
  47. }
  48. return &types.Project{
  49. ID: p.ID,
  50. Name: p.Name,
  51. Roles: roles,
  52. }
  53. }