environment_config.go 923 B

12345678910111213141516171819202122232425262728293031323334353637
  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. PreviewEnvironments []PreviewEnvironment
  18. PorterApps []PorterApp
  19. }
  20. func (c *EnvironmentConfig) ToEnvironmentConfigType() *types.EnvironmentConfig {
  21. return &types.EnvironmentConfig{
  22. ID: c.Model.ID,
  23. ProjectID: c.ProjectID,
  24. ClusterID: c.ClusterID,
  25. GitInstallationID: c.GitInstallationID,
  26. Name: c.Name,
  27. Auto: c.Auto,
  28. }
  29. }