Skip to content

Commit 68824a5

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 09ee495 commit 68824a5

File tree

7 files changed

+29
-36
lines changed

7 files changed

+29
-36
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/addon.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $addonVersion $.Values.secretName }}
31+
{{- if or $addonVersion $.Values.secretName $.Values.configSecret.name (($addon).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $addonVersion }}
3535
version: {{ $addonVersion }}
3636
{{- end }}
37+
{{- if (default (($addon).configSecret).name (($.Values).configSecret).name) }}
38+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $addon) | nindent 2 }}
39+
{{- end }}
3740
{{- if $.Values.secretName }}
3841
secretName: {{ $.Values.secretName }}
3942
{{- end }}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,14 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $bootstrapVersion $.Values.configSecret.name }}
31+
{{- if or $bootstrapVersion $.Values.configSecret.name (($bootstrap).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $bootstrapVersion }}
3535
version: {{ $bootstrapVersion }}
3636
{{- end }}
37-
{{- if $.Values.configSecret.name }}
38-
configSecret:
39-
name: {{ $.Values.configSecret.name }}
40-
{{- if $.Values.configSecret.namespace }}
41-
namespace: {{ $.Values.configSecret.namespace }}
42-
{{- end }}
37+
{{- if (default (($bootstrap).configSecret).name (($.Values).configSecret).name) }}
38+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $bootstrap) | nindent 2 }}
4339
{{- end }}
4440
{{- if $bootstrap.manifestPatches }}
4541
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
@@ -28,7 +28,7 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager }}
31+
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager (($controlPlane).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $controlPlaneVersion }}
@@ -47,12 +47,8 @@ spec:
4747
{{- end }}
4848
{{- end }}
4949
{{- end }}
50-
{{- if $.Values.configSecret.name }}
51-
configSecret:
52-
name: {{ $.Values.configSecret.name }}
53-
{{- if $.Values.configSecret.namespace }}
54-
namespace: {{ $.Values.configSecret.namespace }}
55-
{{- end }}
50+
{{- if (default (($controlPlane).configSecret).name (($.Values).configSecret).name) }}
51+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $controlPlane) | nindent 2 }}
5652
{{- end }}
5753
{{- if $controlPlane.manifestPatches }}
5854
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
@@ -28,7 +28,7 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager }}
31+
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager (($core).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $coreVersion }}
@@ -43,12 +43,8 @@ spec:
4343
{{- end }}
4444
{{- end }}
4545
{{- end }}
46-
{{- if $.Values.configSecret.name }}
47-
configSecret:
48-
name: {{ $.Values.configSecret.name }}
49-
{{- if $.Values.configSecret.namespace }}
50-
namespace: {{ $.Values.configSecret.namespace }}
51-
{{- end }}
46+
{{- if (default (($core).configSecret).name (($.Values).configSecret).name) }}
47+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $core) | nindent 2 }}
5248
{{- end }}
5349
{{- if $core.manifestPatches }}
5450
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
@@ -28,7 +28,7 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $infrastructureVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
31+
{{- if or $infrastructureVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments (($infra).configSecret).name }}
3232
spec:
3333
{{- end }}
3434
{{- if $infrastructureVersion }}
@@ -57,12 +57,8 @@ spec:
5757
{{- end }}
5858
{{- end }}
5959
{{- end }}
60-
{{- if $.Values.configSecret.name }}
61-
configSecret:
62-
name: {{ $.Values.configSecret.name }}
63-
{{- if $.Values.configSecret.namespace }}
64-
namespace: {{ $.Values.configSecret.namespace }}
65-
{{- end }}
60+
{{- if (default (($infra).configSecret).name (($.Values).configSecret).name) }}
61+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $infra) | nindent 2 }}
6662
{{- end }}
6763
{{- if $.Values.additionalDeployments }}
6864
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
@@ -28,7 +28,7 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $ipamVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments }}
31+
{{- if or $ipamVersion $.Values.configSecret.name $.Values.manager $.Values.additionalDeployments (($ipam).configSecret).name }}
3232
spec:
3333
{{- end }}
3434
{{- if $ipamVersion }}
@@ -57,12 +57,8 @@ spec:
5757
{{- end }}
5858
{{- end }}
5959
{{- end }}
60-
{{- if $.Values.configSecret.name }}
61-
configSecret:
62-
name: {{ $.Values.configSecret.name }}
63-
{{- if $.Values.configSecret.namespace }}
64-
namespace: {{ $.Values.configSecret.namespace }}
65-
{{- end }}
60+
{{- if (default (($ipam).configSecret).name (($.Values).configSecret).name) }}
61+
{{- include "capi-operator.configSecret" (dict "ROOT" $ "ARGUMENT" $ipam) | nindent 2 }}
6662
{{- end }}
6763
{{- if $ipam.manifestPatches }}
6864
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}

0 commit comments

Comments
 (0)