project.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // Project type that extends gorm.Model
  8. type Project struct {
  9. gorm.Model
  10. Name string `json:"name"`
  11. Roles []Role `json:"roles"`
  12. // linked repos
  13. GitRepos []GitRepo `json:"git_repos,omitempty"`
  14. // linked registries
  15. Registries []Registry `json:"registries,omitempty"`
  16. // linked clusters
  17. Clusters []Cluster `json:"clusters"`
  18. ClusterCandidates []ClusterCandidate `json:"cluster_candidates"`
  19. // linked helm repos
  20. HelmRepos []HelmRepo `json:"helm_repos"`
  21. // invitations to the project
  22. Invites []Invite `json:"invites"`
  23. // provisioned aws infra
  24. Infras []Infra `json:"infras"`
  25. // auth mechanisms
  26. KubeIntegrations []ints.KubeIntegration `json:"kube_integrations"`
  27. BasicIntegrations []ints.BasicIntegration `json:"basic_integrations"`
  28. OIDCIntegrations []ints.OIDCIntegration `json:"oidc_integrations"`
  29. OAuthIntegrations []ints.OAuthIntegration `json:"oauth_integrations"`
  30. AWSIntegrations []ints.AWSIntegration `json:"aws_integrations"`
  31. GCPIntegrations []ints.GCPIntegration `json:"gcp_integrations"`
  32. }
  33. // ToProjectType generates an external types.Project to be shared over REST
  34. func (p *Project) ToProjectType() *types.Project {
  35. roles := make([]*types.Role, 0)
  36. for _, role := range p.Roles {
  37. roles = append(roles, role.ToRoleType())
  38. }
  39. return &types.Project{
  40. ID: p.ID,
  41. Name: p.Name,
  42. Roles: roles,
  43. }
  44. }