Skip to content

Commit dadb228

Browse files
committed
feat: restructure chart values to allow for extending mappings
This commit breaks the colon separated string into multiple key-value pairs. This is in preparation for extension points to the chart. BREAKING CHANGE: This changes the format of the values.yaml file. Chart uses must make adaptations.
1 parent 446aa87 commit dadb228

File tree

7 files changed

+54
-148
lines changed

7 files changed

+54
-148
lines changed
Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Addon provider
2-
{{- if .Values.addon }}
3-
{{- $addons := split ";" .Values.addon }}
4-
{{- $addonNamespace := "" }}
5-
{{- $addonName := "" }}
6-
{{- $addonVersion := "" }}
7-
{{- range $addon := $addons }}
8-
{{- $addonArgs := split ":" $addon }}
9-
{{- $addonArgsLen := len $addonArgs }}
10-
{{- if eq $addonArgsLen 3 }}
11-
{{- $addonNamespace = $addonArgs._0 }}
12-
{{- $addonName = $addonArgs._1 }}
13-
{{- $addonVersion = $addonArgs._2 }}
14-
{{- else if eq $addonArgsLen 2 }}
15-
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
16-
{{- $addonName = $addonArgs._0 }}
17-
{{- $addonVersion = $addonArgs._1 }}
18-
{{- else if eq $addonArgsLen 1 }}
19-
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
20-
{{- $addonName = $addonArgs._0 }}
21-
{{- else }}
22-
{{- fail "addon provider argument should have the following format helm:v1.0.0 or mynamespace:helm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $addon := $.Values.addon }}
3+
{{- $addonNamespace := default ( printf "%s-%s" $name "addon-system" ) (get $addon "namespace") }}
4+
{{- $addonName := $name }}
5+
{{- $addonVersion := get $addon "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -52,5 +34,4 @@ spec:
5234
{{- if $.Values.secretNamespace }}
5335
secretNamespace: {{ $.Values.secretNamespace }}
5436
{{- end }}
55-
{{- end }} {{/* range $addon := $addons */}}
56-
{{- end }} {{/* if .Values.addon */}}
37+
{{- end }} {{/* range $name, $addon := .Values.addon */}}
Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Bootstrap provider
2-
{{- if .Values.bootstrap }}
3-
{{- $bootstraps := split ";" .Values.bootstrap }}
4-
{{- $bootstrapNamespace := "" }}
5-
{{- $bootstrapName := "" }}
6-
{{- $bootstrapVersion := "" }}
7-
{{- range $bootstrap := $bootstraps }}
8-
{{- $bootstrapArgs := split ":" $bootstrap }}
9-
{{- $bootstrapArgsLen := len $bootstrapArgs }}
10-
{{- if eq $bootstrapArgsLen 3 }}
11-
{{- $bootstrapNamespace = $bootstrapArgs._0 }}
12-
{{- $bootstrapName = $bootstrapArgs._1 }}
13-
{{- $bootstrapVersion = $bootstrapArgs._2 }}
14-
{{- else if eq $bootstrapArgsLen 2 }}
15-
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
16-
{{- $bootstrapName = $bootstrapArgs._0 }}
17-
{{- $bootstrapVersion = $bootstrapArgs._1 }}
18-
{{- else if eq $bootstrapArgsLen 1 }}
19-
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
20-
{{- $bootstrapName = $bootstrapArgs._0 }}
21-
{{- else }}
22-
{{- fail "bootstrap provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $bootstrap := $.Values.bootstrap }}
3+
{{- $bootstrapNamespace := default ( printf "%s-%s" $name "bootstrap-system" ) (get $bootstrap "namespace") }}
4+
{{- $bootstrapName := $name }}
5+
{{- $bootstrapVersion := get $bootstrap "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -51,5 +33,4 @@ spec:
5133
namespace: {{ $.Values.configSecret.namespace }}
5234
{{- end }}
5335
{{- end }}
54-
{{- end }} {{/* range $bootstrap := $bootstraps */}}
55-
{{- end }} {{/* if .Values.bootstrap */}}
36+
{{- end }} {{/* range $name, $bootstrap := .Values.bootstrap */}}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Control plane provider
2-
{{- if .Values.controlPlane }}
3-
{{- $controlPlanes := split ";" .Values.controlPlane }}
4-
{{- $controlPlaneNamespace := "" }}
5-
{{- $controlPlaneName := "" }}
6-
{{- $controlPlaneVersion := "" }}
7-
{{- range $controlPlane := $controlPlanes }}
8-
{{- $controlPlaneArgs := split ":" $controlPlane }}
9-
{{- $controlPlaneArgsLen := len $controlPlaneArgs }}
10-
{{- if eq $controlPlaneArgsLen 3 }}
11-
{{- $controlPlaneNamespace = $controlPlaneArgs._0 }}
12-
{{- $controlPlaneName = $controlPlaneArgs._1 }}
13-
{{- $controlPlaneVersion = $controlPlaneArgs._2 }}
14-
{{- else if eq $controlPlaneArgsLen 2 }}
15-
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
16-
{{- $controlPlaneName = $controlPlaneArgs._0 }}
17-
{{- $controlPlaneVersion = $controlPlaneArgs._1 }}
18-
{{- else if eq $controlPlaneArgsLen 1 }}
19-
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
20-
{{- $controlPlaneName = $controlPlaneArgs._0 }}
21-
{{- else }}
22-
{{- fail "controlplane provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $controlPlane := $.Values.controlPlane }}
3+
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
4+
{{- $controlPlaneName := $name }}
5+
{{- $controlPlaneVersion := get $controlPlane "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -64,5 +46,4 @@ spec:
6446
namespace: {{ $.Values.configSecret.namespace }}
6547
{{- end }}
6648
{{- end }}
67-
{{- end }} {{/* range $controlPlane := $controlPlanes */}}
68-
{{- end }} {{/* if .Values.controlPlane */}}
49+
{{- end }} {{/* range $name, $controlPlane := .Values.controlPlane */}}

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
# Core provider
2-
{{- if .Values.core }}
3-
{{- $coreArgs := split ":" .Values.core }}
4-
{{- $coreArgsLen := len $coreArgs }}
5-
{{- $coreVersion := "" }}
6-
{{- $coreNamespace := "" }}
7-
{{- $coreName := "" }}
8-
{{- $coreVersion := "" }}
9-
{{- if eq $coreArgsLen 3 }}
10-
{{- $coreNamespace = $coreArgs._0 }}
11-
{{- $coreName = $coreArgs._1 }}
12-
{{- $coreVersion = $coreArgs._2 }}
13-
{{- else if eq $coreArgsLen 2 }}
14-
{{- $coreNamespace = "capi-system" }}
15-
{{- $coreName = $coreArgs._0 }}
16-
{{- $coreVersion = $coreArgs._1 }}
17-
{{- else if eq $coreArgsLen 1 }}
18-
{{- $coreNamespace = "capi-system" }}
19-
{{- $coreName = $coreArgs._0 }}
20-
{{- else }}
21-
{{- fail "core provider argument should have the following format cluster-api:v1.0.0 or mynamespace:cluster-api:v1.0.0" }}
22-
{{- end }}
2+
{{- range $name, $core := $.Values.core }}
3+
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
4+
{{- $coreName := $name }}
5+
{{- $coreVersion := get $core "version" }}
236
---
247
apiVersion: v1
258
kind: Namespace
@@ -60,4 +43,4 @@ spec:
6043
namespace: {{ $.Values.configSecret.namespace }}
6144
{{- end }}
6245
{{- end }}
63-
{{- end }} {{/* if .Values.core */}}
46+
{{- end }} {{/* range $name, $core := .Values.core */}}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Infrastructure providers
2-
{{- if .Values.infrastructure }}
3-
{{- $infrastructures := split ";" .Values.infrastructure }}
4-
{{- $infrastructureNamespace := "" }}
5-
{{- $infrastructureName := "" }}
6-
{{- $infrastructureVersion := "" }}
7-
{{- range $infrastructure := $infrastructures }}
8-
{{- $infrastructureArgs := split ":" $infrastructure }}
9-
{{- $infrastructureArgsLen := len $infrastructureArgs }}
10-
{{- if eq $infrastructureArgsLen 3 }}
11-
{{- $infrastructureNamespace = $infrastructureArgs._0 }}
12-
{{- $infrastructureName = $infrastructureArgs._1 }}
13-
{{- $infrastructureVersion = $infrastructureArgs._2 }}
14-
{{- else if eq $infrastructureArgsLen 2 }}
15-
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
16-
{{- $infrastructureName = $infrastructureArgs._0 }}
17-
{{- $infrastructureVersion = $infrastructureArgs._1 }}
18-
{{- else if eq $infrastructureArgsLen 1 }}
19-
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
20-
{{- $infrastructureName = $infrastructureArgs._0 }}
21-
{{- else }}
22-
{{- fail "infrastructure provider argument should have the following format aws:v1.0.0 or mynamespace:aws:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $infra := $.Values.infrastructure }}
3+
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
4+
{{- $infrastructureName := $name }}
5+
{{- $infrastructureVersion := get $infra "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -79,5 +61,4 @@ spec:
7961
{{- if $.Values.additionalDeployments }}
8062
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
8163
{{- end }}
82-
{{- end }} {{/* range $infrastructure := $infrastructures */}}
83-
{{- end }} {{/* if .Values.infrastructure */}}
64+
{{- end }} {{/* range $name, $infra := .Values.infrastructure */}}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# IPAM providers
2-
{{- if .Values.ipam }}
3-
{{- $ipams := split ";" .Values.ipam }}
4-
{{- $ipamNamespace := "" }}
5-
{{- $ipamName := "" }}
6-
{{- $ipamVersion := "" }}
7-
{{- range $ipam := $ipams }}
8-
{{- $ipamArgs := split ":" $ipam }}
9-
{{- $ipamArgsLen := len $ipamArgs }}
10-
{{- if eq $ipamArgsLen 3 }}
11-
{{- $ipamNamespace = $ipamArgs._0 }}
12-
{{- $ipamName = $ipamArgs._1 }}
13-
{{- $ipamVersion = $ipamArgs._2 }}
14-
{{- else if eq $ipamArgsLen 2 }}
15-
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
16-
{{- $ipamName = $ipamArgs._0 }}
17-
{{- $ipamVersion = $ipamArgs._1 }}
18-
{{- else if eq $ipamArgsLen 1 }}
19-
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
20-
{{- $ipamName = $ipamArgs._0 }}
21-
{{- else }}
22-
{{- fail "ipam provider argument should have the following format in-cluster:v1.0.0 or mynamespace:in-cluster:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $ipam := $.Values.ipam }}
3+
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
4+
{{- $ipamName := $name }}
5+
{{- $ipamVersion := get $ipam "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -69,5 +51,4 @@ spec:
6951
{{- if $.Values.additionalDeployments }}
7052
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
7153
{{- end }}
72-
{{- end }} {{/* range $ipam := $ipams */}}
73-
{{- end }} {{/* if .Values.ipam */}}
54+
{{- end }} {{/* range $name, $ipam := .Values.ipam */}}

hack/charts/cluster-api-operator/values.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
---
22
# ---
33
# Cluster API provider options
4-
core: ""
5-
bootstrap: ""
6-
controlPlane: ""
7-
infrastructure: ""
8-
ipam: ""
9-
addon: ""
4+
core: {}
5+
# cluster-api: {} # Name, required
6+
# namespace: "" # Optional
7+
# version: "" # Optional
8+
bootstrap: {}
9+
# kubeadm: {} # Name, required
10+
# namespace: "" # Optional
11+
# version: "" # Optional
12+
controlPlane: {}
13+
# kubeadm: {} # Name, required
14+
# namespace: "" # Optional
15+
# version: "" # Optional
16+
infrastructure: {}
17+
# docker: {} # Name, required
18+
# namespace: "" # Optional
19+
# version: "" # Optional
20+
addon: {}
21+
# helm: {} # Name, required
22+
# namespace: "" # Optional
23+
# version: "" # Optional
24+
ipam: {}
25+
# in-cluster: {} # Name, required
26+
# namespace: "" # Optional
27+
# version: "" # Optional
1028
manager.featureGates: {}
1129
fetchConfig: {}
1230
# ---

0 commit comments

Comments
 (0)