Skip to content

Commit fd7bae6

Browse files
authored
Merge pull request #780 from rbjorklin/make-config-secret-configurable-per-component
✨ Make configSecret configurable per component
2 parents fb2f897 + 4fdac3e commit fd7bae6

15 files changed

+79
-37
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: 7 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 }}
@@ -43,6 +46,9 @@ spec:
4346
{{- if $addon.manifestPatches }}
4447
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
4548
{{- end }}
49+
{{- if $addon.fetchConfig }}
50+
fetchConfig: {{ toYaml $addon.fetchConfig | nindent 4 }}
51+
{{- end }}
4652
{{- if $addon.additionalManifests }}
4753
additionalManifests:
4854
name: {{ $addon.additionalManifests.name }}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,21 @@ 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 }}
4642
{{- end }}
43+
{{- if $bootstrap.fetchConfig }}
44+
fetchConfig: {{ toYaml $bootstrap.fetchConfig | nindent 4 }}
45+
{{- end }}
4746
{{- if $bootstrap.additionalManifests }}
4847
additionalManifests:
4948
name: {{ $bootstrap.additionalManifests.name }}

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

Lines changed: 6 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,16 +47,15 @@ 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 }}
5955
{{- end }}
56+
{{- if $controlPlane.fetchConfig }}
57+
fetchConfig: {{ toYaml $controlPlane.fetchConfig | nindent 4 }}
58+
{{- end }}
6059
{{- if $controlPlane.additionalManifests }}
6160
additionalManifests:
6261
name: {{ $controlPlane.additionalManifests.name }}

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

Lines changed: 6 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,16 +43,15 @@ 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 }}
5551
{{- end }}
52+
{{- if $core.fetchConfig }}
53+
fetchConfig: {{ toYaml $core.fetchConfig | nindent 4 }}
54+
{{- end }}
5655
{{- if $core.additionalManifests }}
5756
additionalManifests:
5857
name: {{ $core.additionalManifests.name }}

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

Lines changed: 6 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,19 +57,18 @@ 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 }}
6965
{{- end }}
7066
{{- if $infra.manifestPatches }}
7167
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
7268
{{- end }} {{/* if $infra.manifestPatches */}}
69+
{{- if $infra.fetchConfig }}
70+
fetchConfig: {{ toYaml $infra.fetchConfig | nindent 4 }}
71+
{{- end }}
7372
{{- if $infra.additionalManifests }}
7473
additionalManifests:
7574
name: {{ $infra.additionalManifests.name }}

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

Lines changed: 6 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,16 +57,15 @@ 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 }}
6965
{{- end }}
66+
{{- if $ipam.fetchConfig }}
67+
fetchConfig: {{ toYaml $ipam.fetchConfig | nindent 4 }}
68+
{{- end }}
7069
{{- if $.Values.additionalDeployments }}
7170
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
7271
{{- end }}

hack/charts/cluster-api-operator/values.schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema#",
33
"type": "object",
44
"properties": {
5+
"fetchConfig": {
6+
"type": "object",
7+
"deprecated": true,
8+
"description": "This field is deprecated and will be removed in future versions. Prefer declaring fetchConfig under the individual providers instead."
9+
},
510
"core": {
611
"oneOf": [
712
{ "type": "object" },

test/e2e/resources/all-providers-custom-ns-versions.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ metadata:
7171
"argocd.argoproj.io/sync-wave": "2"
7272
spec:
7373
version: v0.2.6
74+
configSecret:
75+
name: test-secret-name
76+
namespace: test-secret-namespace
7477
---
7578
# Source: cluster-api-operator/templates/bootstrap.yaml
7679
apiVersion: operator.cluster.x-k8s.io/v1alpha2

test/e2e/resources/all-providers-custom-versions.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ metadata:
7171
"argocd.argoproj.io/sync-wave": "2"
7272
spec:
7373
version: v0.2.6
74+
configSecret:
75+
name: test-secret-name
76+
namespace: test-secret-namespace
7477
---
7578
# Source: cluster-api-operator/templates/bootstrap.yaml
7679
apiVersion: operator.cluster.x-k8s.io/v1alpha2

0 commit comments

Comments
 (0)