diff --git a/config/v2/config.go b/config/v2/config.go index 707247020..c8ec2f8ab 100644 --- a/config/v2/config.go +++ b/config/v2/config.go @@ -127,6 +127,7 @@ type Providers struct { Heroku *HerokuProvider `yaml:"heroku,omitempty"` Kubernetes *KubernetesProvider `yaml:"kubernetes,omitempty"` Okta *OktaProvider `yaml:"okta,omitempty"` + OpsGenie *OpsGenieProvider `yaml:"opsgenie,omitempty"` Pagerduty *PagerdutyProvider `yaml:"pagerduty,omitempty"` Sentry *SentryProvider `yaml:"sentry,omitempty"` Snowflake *SnowflakeProvider `yaml:"snowflake,omitempty"` @@ -214,6 +215,10 @@ type PagerdutyProvider struct { Version *string `yaml:"version,omitempty"` } +type OpsGenieProvider struct { + Version *string `yaml:"version,omitempty"` +} + type DatabricksProvider struct { Version *string `yaml:"version,omitempty"` } @@ -484,6 +489,13 @@ func (c *Config) Generate(r *rand.Rand, size int) reflect.Value { return nil } + randOpsGenieProvider := func(r *rand.Rand) *OpsGenieProvider { + if r.Float32() < 0.5 { + return &OpsGenieProvider{} + } + return nil + } + randDatabricksProvider := func(r *rand.Rand) *DatabricksProvider { if r.Float32() < 0.5 { return &DatabricksProvider{} @@ -544,6 +556,7 @@ func (c *Config) Generate(r *rand.Rand, size int) reflect.Value { Heroku: randHerokuProvider(r), Kubernetes: randKubernetesProvider(r), Okta: randOktaProvider(r, s), + OpsGenie: randOpsGenieProvider(r), Sentry: randSentryProvider(r), Snowflake: randSnowflakeProvider(r, s), }, diff --git a/config/v2/resolvers.go b/config/v2/resolvers.go index fa730b6e3..f05c00e7c 100644 --- a/config/v2/resolvers.go +++ b/config/v2/resolvers.go @@ -361,6 +361,25 @@ func ResolvePagerdutyProvider(commons ...Common) *PagerdutyProvider { return p } +func ResolveOpsGenieProvider(commons ...Common) *OpsGenieProvider { + var p *OpsGenieProvider + for _, c := range commons { + if c.Providers == nil || c.Providers.OpsGenie == nil { + continue + } + p = c.Providers.OpsGenie + } + + version := lastNonNil(OpsGenieProviderVersionGetter, commons...) + + if version != nil { + return &OpsGenieProvider{ + Version: version, + } + } + return p +} + func ResolveDatabricksProvider(commons ...Common) *DatabricksProvider { var p *DatabricksProvider for _, c := range commons { @@ -783,6 +802,13 @@ func PagerdutyProviderVersionGetter(comm Common) *string { return comm.Providers.Pagerduty.Version } +func OpsGenieProviderVersionGetter(comm Common) *string { + if comm.Providers == nil || comm.Providers.OpsGenie == nil { + return nil + } + return comm.Providers.OpsGenie.Version +} + func DatabricksProviderVersionGetter(comm Common) *string { if comm.Providers == nil || comm.Providers.Databricks == nil { return nil diff --git a/plan/plan.go b/plan/plan.go index 5282cad12..06a61b0f9 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -748,6 +748,14 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon { } } + opsGenieConfig := v2.ResolveOpsGenieProvider(commons...) + if opsGenieConfig != nil { + providerVersions["opsgenie"] = ProviderVersion{ + Source: "opsgenie/opsgenie", + Version: opsGenieConfig.Version, + } + } + databricksConfig := v2.ResolveDatabricksProvider(commons...) if databricksConfig != nil { providerVersions["databricks"] = ProviderVersion{