environment_config.go 881 B

123456789101112131415161718192021222324252627282930313233343536
  1. package models
  2. import (
  3. "github.com/porter-dev/porter/api/types"
  4. "gorm.io/gorm"
  5. )
  6. // Environment Config type used to set up an instance of an environment
  7. type EnvironmentConfig struct {
  8. gorm.Model
  9. ProjectID uint
  10. ClusterID uint `gorm:"uniqueIndex:idx_cluster_id_name"`
  11. GitInstallationID uint
  12. WebhookID string `gorm:"unique"`
  13. GithubWebhookID int64
  14. Name string `gorm:"uniqueIndex:idx_cluster_id_name"`
  15. Auto bool `gorm:"default:false"`
  16. IsDefault bool `gorm:"default:false"`
  17. PorterApps []PorterApp
  18. }
  19. func (c *EnvironmentConfig) ToEnvironmentConfigType() *types.EnvironmentConfig {
  20. return &types.EnvironmentConfig{
  21. ID: c.Model.ID,
  22. ProjectID: c.ProjectID,
  23. ClusterID: c.ClusterID,
  24. GitInstallationID: c.GitInstallationID,
  25. Name: c.Name,
  26. Auto: c.Auto,
  27. }
  28. }