project.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 databases
  29. Databases []Database `json:"databases"`
  30. // linked helm repos
  31. HelmRepos []HelmRepo `json:"helm_repos"`
  32. // invitations to the project
  33. Invites []Invite `json:"invites"`
  34. // provisioned aws infra
  35. Infras []Infra `json:"infras"`
  36. // configured environments
  37. EnvironmentConfigs []EnvironmentConfig `json:"environment_configs"`
  38. // auth mechanisms
  39. KubeIntegrations []ints.KubeIntegration `json:"kube_integrations"`
  40. BasicIntegrations []ints.BasicIntegration `json:"basic_integrations"`
  41. OIDCIntegrations []ints.OIDCIntegration `json:"oidc_integrations"`
  42. OAuthIntegrations []ints.OAuthIntegration `json:"oauth_integrations"`
  43. AWSIntegrations []ints.AWSIntegration `json:"aws_integrations"`
  44. GCPIntegrations []ints.GCPIntegration `json:"gcp_integrations"`
  45. AzureIntegrations []ints.AzureIntegration `json:"azure_integrations"`
  46. GitlabIntegrations []ints.GitlabIntegration `json:"gitlab_integrations"`
  47. PreviewEnvsEnabled bool
  48. RDSDatabasesEnabled bool
  49. ManagedInfraEnabled bool
  50. StacksEnabled bool
  51. APITokensEnabled bool
  52. CapiProvisionerEnabled bool
  53. SimplifiedViewEnabled bool
  54. AzureEnabled bool
  55. HelmValuesEnabled bool
  56. EnvGroupEnabled bool `gorm:"default:false"`
  57. }
  58. // ToProjectType generates an external types.Project to be shared over REST
  59. func (p *Project) ToProjectType() *types.Project {
  60. roles := make([]*types.Role, 0)
  61. for _, role := range p.Roles {
  62. roles = append(roles, role.ToRoleType())
  63. }
  64. return &types.Project{
  65. ID: p.ID,
  66. Name: p.Name,
  67. Roles: roles,
  68. PreviewEnvsEnabled: p.PreviewEnvsEnabled,
  69. RDSDatabasesEnabled: p.RDSDatabasesEnabled,
  70. ManagedInfraEnabled: p.ManagedInfraEnabled,
  71. StacksEnabled: p.StacksEnabled,
  72. APITokensEnabled: p.APITokensEnabled,
  73. CapiProvisionerEnabled: p.CapiProvisionerEnabled,
  74. SimplifiedViewEnabled: p.SimplifiedViewEnabled,
  75. AzureEnabled: p.AzureEnabled,
  76. HelmValuesEnabled: p.HelmValuesEnabled,
  77. EnvGroupEnabled: p.EnvGroupEnabled,
  78. }
  79. }