project.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // auth mechanisms
  37. KubeIntegrations []ints.KubeIntegration `json:"kube_integrations"`
  38. BasicIntegrations []ints.BasicIntegration `json:"basic_integrations"`
  39. OIDCIntegrations []ints.OIDCIntegration `json:"oidc_integrations"`
  40. OAuthIntegrations []ints.OAuthIntegration `json:"oauth_integrations"`
  41. AWSIntegrations []ints.AWSIntegration `json:"aws_integrations"`
  42. GCPIntegrations []ints.GCPIntegration `json:"gcp_integrations"`
  43. AzureIntegrations []ints.AzureIntegration `json:"azure_integrations"`
  44. GitlabIntegrations []ints.GitlabIntegration `json:"gitlab_integrations"`
  45. PreviewEnvsEnabled bool
  46. RDSDatabasesEnabled bool
  47. ManagedInfraEnabled bool
  48. StacksEnabled bool
  49. APITokensEnabled bool
  50. CapiProvisionerEnabled bool
  51. SimplifiedViewEnabled bool
  52. AzureEnabled bool
  53. HelmValuesEnabled bool
  54. EnvGroupEnabled bool
  55. MultiCluster bool `gorm:"default:false"`
  56. }
  57. // ToProjectType generates an external types.Project to be shared over REST
  58. func (p *Project) ToProjectType() *types.Project {
  59. roles := make([]*types.Role, 0)
  60. for _, role := range p.Roles {
  61. roles = append(roles, role.ToRoleType())
  62. }
  63. return &types.Project{
  64. ID: p.ID,
  65. Name: p.Name,
  66. Roles: roles,
  67. PreviewEnvsEnabled: p.PreviewEnvsEnabled,
  68. RDSDatabasesEnabled: p.RDSDatabasesEnabled,
  69. ManagedInfraEnabled: p.ManagedInfraEnabled,
  70. StacksEnabled: p.StacksEnabled,
  71. APITokensEnabled: p.APITokensEnabled,
  72. CapiProvisionerEnabled: p.CapiProvisionerEnabled,
  73. SimplifiedViewEnabled: p.SimplifiedViewEnabled,
  74. AzureEnabled: p.AzureEnabled,
  75. HelmValuesEnabled: p.HelmValuesEnabled,
  76. EnvGroupEnabled: p.EnvGroupEnabled,
  77. MultiCluster: p.MultiCluster,
  78. }
  79. }