Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeyheath committed Apr 25, 2024
1 parent a3e8b56 commit 304b06f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
6 changes: 2 additions & 4 deletions config/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,11 @@ type KubernetesProvider struct {
}

type HelmProvider struct {
CommonProvider `yaml:",inline"`
ClusterComponentName *string `yaml:"cluster_component_name,omitempty"`
CommonProvider `yaml:",inline"`
}

type KubectlProvider struct {
CommonProvider `yaml:",inline"`
ClusterComponentName *string `yaml:"cluster_component_name,omitempty"`
CommonProvider `yaml:",inline"`
}

// Backend is used to configure a terraform backend
Expand Down
4 changes: 0 additions & 4 deletions config/v2/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,8 @@ func ResolveHelmProvider(commons ...Common) *HelmProvider {
}
}
}
clusterComponentName := lastNonNil(KubernetesProviderClusterComponentNameGetter, commons...)
if version != nil {
return &HelmProvider{
ClusterComponentName: clusterComponentName,
CommonProvider: CommonProvider{
CustomProvider: lastNonNilBool(HelmProviderCustomProviderGetter, commons...),
Enabled: enabled,
Expand Down Expand Up @@ -701,10 +699,8 @@ func ResolveKubectlProvider(commons ...Common) *KubectlProvider {
}
}

clusterComponentName := lastNonNil(KubernetesProviderClusterComponentNameGetter, commons...)
if version != nil {
return &KubectlProvider{
ClusterComponentName: clusterComponentName,
CommonProvider: CommonProvider{
CustomProvider: lastNonNilBool(KubectlProviderCustomProviderGetter, commons...),
Enabled: enabled,
Expand Down
9 changes: 6 additions & 3 deletions templates/templates/common/kubernetes_provider.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{{ define "kubernetes_provider" -}}
{{ if .ClusterComponentName -}}
{{ if .Kubernetes.ClusterComponentName -}}
data "aws_eks_cluster" "cluster" {
name = data.terraform_remote_state.{{ .ClusterComponentName }}.outputs.cluster_id
name = data.terraform_remote_state.{{ .Kubernetes.ClusterComponentName }}.outputs.cluster_id
}

data "aws_eks_cluster_auth" "cluster" {
name = data.terraform_remote_state.{{ .ClusterComponentName }}.outputs.cluster_id
name = data.terraform_remote_state.{{ .Kubernetes.ClusterComponentName }}.outputs.cluster_id
}

provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
}

{{template "helm_provider" .Helm -}}
{{- template "kubectl_provider" .Kubectl -}}
{{ end }}{{ end }}
10 changes: 1 addition & 9 deletions templates/templates/component/terraform/fogg.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,7 @@ variable "TFC_PROJECT_NAME" {
{{ end }}{{ end }}

{{- if .ProviderConfiguration.Kubernetes -}}{{- if not .ProviderConfiguration.Kubernetes.CustomProvider -}}
{{- template "kubernetes_provider" .ProviderConfiguration.Kubernetes -}}
{{- end -}}{{- end -}}

{{- if .ProviderConfiguration.Helm -}}{{- if not .ProviderConfiguration.Helm.CustomProvider -}}
{{- template "helm_provider" .ProviderConfiguration.Helm -}}
{{- end -}}{{- end -}}

{{- if .ProviderConfiguration.Kubectl -}}{{- if not .ProviderConfiguration.Kubectl.CustomProvider -}}
{{- template "kubectl_provider" .ProviderConfiguration.Kubectl -}}
{{- template "kubernetes_provider" .ProviderConfiguration -}}
{{- end -}}{{- end -}}

terraform {
Expand Down

0 comments on commit 304b06f

Please sign in to comment.