Skip to content

Commit

Permalink
feat: SPIKE: Add helm provider support to fogg (#865)
Browse files Browse the repository at this point in the history
* feat: SPIKE: Add helm provider support to fogg

* Update outputs.tf

* Update outputs.tf
  • Loading branch information
alexlokshin-czi authored May 23, 2023
1 parent dfe5092 commit 0e8cbfb
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type Providers struct {
Grafana *GrafanaProvider `yaml:"grafana,omitempty"`
Heroku *HerokuProvider `yaml:"heroku,omitempty"`
Kubernetes *KubernetesProvider `yaml:"kubernetes,omitempty"`
Helm *HelmProvider `yaml:"helm,omitempty"`
Okta *OktaProvider `yaml:"okta,omitempty"`
OpsGenie *OpsGenieProvider `yaml:"opsgenie,omitempty"`
Pagerduty *PagerdutyProvider `yaml:"pagerduty,omitempty"`
Expand Down Expand Up @@ -255,6 +256,10 @@ type KubernetesProvider struct {
CommonProvider `yaml:",inline"`
}

type HelmProvider struct {
CommonProvider `yaml:",inline"`
}

type KubectlProvider struct {
CommonProvider `yaml:",inline"`
}
Expand Down
47 changes: 47 additions & 0 deletions config/v2/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,46 @@ func ResolveKubernetesProvider(commons ...Common) *KubernetesProvider {
return p
}

func ResolveHelmProvider(commons ...Common) *HelmProvider {
var p *HelmProvider
for _, c := range commons {
if c.Providers == nil || c.Providers.Helm == nil {
continue
}
p = c.Providers.Helm
if p.CustomProvider == nil {
p.CustomProvider = defaultEnabled(false)
}
}
var version *string
var enabled *bool

for _, c := range commons {
if c.Providers != nil && c.Providers.Helm != nil {
t := c.Providers.Helm

if t.Enabled != nil {
enabled = t.Enabled
}

if t.Version != nil {
version = t.Version
}
}
}

if version != nil {
return &HelmProvider{
CommonProvider: CommonProvider{
CustomProvider: lastNonNilBool(HelmProviderCustomProviderGetter, commons...),
Enabled: enabled,
Version: version,
},
}
}
return p
}

func ResolveKubectlProvider(commons ...Common) *KubectlProvider {
var p *KubectlProvider
for _, c := range commons {
Expand Down Expand Up @@ -974,6 +1014,13 @@ func KubernetesProviderCustomProviderGetter(comm Common) *bool {
return nil
}

func HelmProviderCustomProviderGetter(comm Common) *bool {
if comm.Providers != nil && comm.Providers.Helm != nil {
return comm.Providers.Helm.CommonProvider.CustomProvider
}
return nil
}

func KubectlProviderCustomProviderGetter(comm Common) *bool {
if comm.Providers != nil && comm.Providers.Kubectl != nil {
return comm.Providers.Kubectl.CommonProvider.CustomProvider
Expand Down
36 changes: 34 additions & 2 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ type ProviderConfiguration struct {
Grafana *GrafanaProvider `yaml:"grafana"`
Heroku *HerokuProvider `yaml:"heroku"`
Kubernetes *KubernetesProvider `yaml:"kubernetes"`
Helm *HelmProvider `yaml:"helm"`
Kubectl *KubectlProvider `yaml:"kubectl"`
Okta *OktaProvider `yaml:"okta"`
Sentry *SentryProvider `yaml:"sentry"`
Expand Down Expand Up @@ -274,6 +275,10 @@ type KubernetesProvider struct {
CommonProvider `yaml:",inline"`
}

type HelmProvider struct {
CommonProvider `yaml:",inline"`
}

type KubectlProvider struct {
CommonProvider `yaml:",inline"`
}
Expand Down Expand Up @@ -1068,7 +1073,7 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
if k8sConfig.CustomProvider != nil {
customProvider = *k8sConfig.CustomProvider
}
version := "2.17.0"
version := "2.20.0"
if k8sConfig.Version != nil {
version = *k8sConfig.Version
}
Expand All @@ -1086,6 +1091,32 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
}
}

var helmPlan *HelmProvider

helmConfig := v2.ResolveHelmProvider(commons...)
if helmConfig != nil && (helmConfig.Enabled == nil || (helmConfig.Enabled != nil && *helmConfig.Enabled)) {
customProvider := false
if helmConfig.CustomProvider != nil {
customProvider = *helmConfig.CustomProvider
}
version := "2.9.0"
if helmConfig.Version != nil {
version = *helmConfig.Version
}
helmPlan = &HelmProvider{
CommonProvider: CommonProvider{
Version: version,
Enabled: helmConfig.Enabled == nil || (helmConfig.Enabled != nil && *helmConfig.Enabled),
CustomProvider: customProvider,
},
}

providerVersions["helm"] = ProviderVersion{
Source: "hashicorp/helm",
Version: &version,
}
}

var kubectlPlan *KubectlProvider

kubcectlConfig := v2.ResolveKubectlProvider(commons...)
Expand Down Expand Up @@ -1120,7 +1151,7 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
if grafanaConfig.CustomProvider != nil {
customProvider = *grafanaConfig.CustomProvider
}
version := "1.34.0"
version := "1.40.1"
if grafanaConfig.Version != nil {
version = *grafanaConfig.Version
}
Expand Down Expand Up @@ -1233,6 +1264,7 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
Grafana: grafanaPlan,
Heroku: herokuPlan,
Kubernetes: k8sPlan,
Helm: helmPlan,
Kubectl: kubectlPlan,
Okta: oktaPlan,
Sentry: sentryPlan,
Expand Down

0 comments on commit 0e8cbfb

Please sign in to comment.