Skip to content

Commit 23e7903

Browse files
committed
feat: make configSecret configurable per component
This makes it so that each component can be configured individually. By making the configuration component specific it is more clear which component is actually using it. This also breaks out a common section into a helper which reduces duplication.
1 parent 4f114a2 commit 23e7903

File tree

6 files changed

+25
-35
lines changed

6 files changed

+25
-35
lines changed

hack/charts/cluster-api-operator/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
2222
{{- end -}}
2323
{{- end -}}
2424
{{- end -}}
25+
26+
{{- define "capi-operator.configSecret" -}}
27+
{{- $ := .ROOT -}}
28+
{{- $arg := .ARGUMENT -}}
29+
configSecret:
30+
name: {{ default (($arg).configSecret).name (($.Values).configSecret).name }}
31+
{{- if (default (($arg).configSecret).namespace (($.Values).configSecret).namespace) }}
32+
namespace: {{ default (($arg).configSecret).namespace (($.Values).configSecret).namespace }}
33+
{{- end }}
34+
{{- end -}}

hack/charts/cluster-api-operator/templates/bootstrap.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,14 @@ metadata:
2626
"helm.sh/hook-weight": "2"
2727
{{- end }}
2828
"argocd.argoproj.io/sync-wave": "2"
29-
{{- if or $bootstrapVersion $.Values.configSecret.name }}
29+
{{- if or $bootstrapVersion $.Values.configSecret.name (($bootstrap).configSecret).name }}
3030
spec:
3131
{{- end}}
3232
{{- if $bootstrapVersion }}
3333
version: {{ $bootstrapVersion }}
3434
{{- end }}
35-
{{- if $.Values.configSecret.name }}
36-
configSecret:
37-
name: {{ $.Values.configSecret.name }}
38-
{{- if $.Values.configSecret.namespace }}
39-
namespace: {{ $.Values.configSecret.namespace }}
40-
{{- end }}
35+
{{- if (default (($bootstrap).configSecret).name (($.Values).configSecret).name) }}
36+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $bootstrap) | nindent 2 }}
4137
{{- end }}
4238
{{- if $bootstrap.manifestPatches }}
4339
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}

hack/charts/cluster-api-operator/templates/control-plane.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ metadata:
2626
"helm.sh/hook-weight": "2"
2727
{{- end }}
2828
"argocd.argoproj.io/sync-wave": "2"
29-
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager }}
29+
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager (($controlPlane).configSecret).name }}
3030
spec:
3131
{{- end}}
3232
{{- if $controlPlaneVersion }}
@@ -45,12 +45,8 @@ spec:
4545
{{- end }}
4646
{{- end }}
4747
{{- end }}
48-
{{- if $.Values.configSecret.name }}
49-
configSecret:
50-
name: {{ $.Values.configSecret.name }}
51-
{{- if $.Values.configSecret.namespace }}
52-
namespace: {{ $.Values.configSecret.namespace }}
53-
{{- end }}
48+
{{- if (default (($controlPlane).configSecret).name (($.Values).configSecret).name) }}
49+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $controlPlane) | nindent 2 }}
5450
{{- end }}
5551
{{- if $controlPlane.manifestPatches }}
5652
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}

hack/charts/cluster-api-operator/templates/core.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ metadata:
2626
"helm.sh/hook-weight": "2"
2727
{{- end }}
2828
"argocd.argoproj.io/sync-wave": "2"
29-
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager }}
29+
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager (($core).configSecret).name }}
3030
spec:
3131
{{- end}}
3232
{{- if $coreVersion }}
@@ -41,12 +41,8 @@ spec:
4141
{{- end }}
4242
{{- end }}
4343
{{- end }}
44-
{{- if $.Values.configSecret.name }}
45-
configSecret:
46-
name: {{ $.Values.configSecret.name }}
47-
{{- if $.Values.configSecret.namespace }}
48-
namespace: {{ $.Values.configSecret.namespace }}
49-
{{- end }}
44+
{{- if (default (($core).configSecret).name (($.Values).configSecret).name) }}
45+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $core) | nindent 2 }}
5046
{{- end }}
5147
{{- if $core.manifestPatches }}
5248
manifestPatches: {{ toYaml $core.manifestPatches | nindent 4 }}

hack/charts/cluster-api-operator/templates/infra.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ metadata:
2626
"helm.sh/hook-weight": "2"
2727
{{- end }}
2828
"argocd.argoproj.io/sync-wave": "2"
29-
{{- if or $infrastructureVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
29+
{{- if or $infrastructureVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments (($infra).configSecret).name }}
3030
spec:
3131
{{- end }}
3232
{{- if $infrastructureVersion }}
@@ -55,12 +55,8 @@ spec:
5555
{{- end }}
5656
{{- end }}
5757
{{- end }}
58-
{{- if $.Values.configSecret.name }}
59-
configSecret:
60-
name: {{ $.Values.configSecret.name }}
61-
{{- if $.Values.configSecret.namespace }}
62-
namespace: {{ $.Values.configSecret.namespace }}
63-
{{- end }}
58+
{{- if (default (($infra).configSecret).name (($.Values).configSecret).name) }}
59+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $infra) | nindent 2 }}
6460
{{- end }}
6561
{{- if $.Values.additionalDeployments }}
6662
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}

hack/charts/cluster-api-operator/templates/ipam.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ metadata:
2626
"helm.sh/hook-weight": "2"
2727
{{- end }}
2828
"argocd.argoproj.io/sync-wave": "2"
29-
{{- if or $ipamVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
29+
{{- if or $ipamVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments (($ipam).configSecret).name }}
3030
spec:
3131
{{- end }}
3232
{{- if $ipamVersion }}
@@ -45,12 +45,8 @@ spec:
4545
{{- end }}
4646
{{- end }}
4747
{{- end }}
48-
{{- if $.Values.configSecret.name }}
49-
configSecret:
50-
name: {{ $.Values.configSecret.name }}
51-
{{- if $.Values.configSecret.namespace }}
52-
namespace: {{ $.Values.configSecret.namespace }}
53-
{{- end }}
48+
{{- if (default (($ipam).configSecret).name (($.Values).configSecret).name) }}
49+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $ipam) | nindent 2 }}
5450
{{- end }}
5551
{{- if $ipam.manifestPatches }}
5652
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}

0 commit comments

Comments
 (0)