Skip to content

Commit

Permalink
feat: Add OpsGenie to fogg (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
alldoami authored Aug 23, 2022
1 parent c061961 commit 1b16ed9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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),
},
Expand Down
26 changes: 26 additions & 0 deletions config/v2/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 1b16ed9

Please sign in to comment.