Skip to content

Commit 7b95c1a

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 34fde4e commit 7b95c1a

File tree

6 files changed

+43
-113
lines changed

6 files changed

+43
-113
lines changed

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# Addon provider
22
{{- 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 }}
3+
{{- range $addon := .Values.addon }}
4+
{{- $addonNamespace := default ( printf "%s-%s" $addon.name "addon-system" ) $addon.namespace }}
5+
{{- $addonName := $addon.name }}
6+
{{- $addonVersion := $addon.version }}
247
---
258
apiVersion: v1
269
kind: Namespace
@@ -52,5 +35,5 @@ spec:
5235
{{- if $.Values.secretNamespace }}
5336
secretNamespace: {{ $.Values.secretNamespace }}
5437
{{- end }}
55-
{{- end }} {{/* range $addon := $addons */}}
38+
{{- end }} {{/* range $addon := .Values.addon */}}
5639
{{- end }} {{/* if .Values.addon */}}

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# Bootstrap provider
22
{{- 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 }}
3+
{{- range $bootstrap := .Values.bootstrap }}
4+
{{- $bootstrapNamespace := default ( printf "%s-%s" $bootstrap.name "bootstrap-system" ) $bootstrap.namespace }}
5+
{{- $bootstrapName := $bootstrap.name }}
6+
{{- $bootstrapVersion := $bootstrap.version }}
247
---
258
apiVersion: v1
269
kind: Namespace
@@ -51,5 +34,5 @@ spec:
5134
namespace: {{ $.Values.configSecret.namespace }}
5235
{{- end }}
5336
{{- end }}
54-
{{- end }} {{/* range $bootstrap := $bootstraps */}}
37+
{{- end }} {{/* range $bootstrap := .Values.bootstrap */}}
5538
{{- end }} {{/* if .Values.bootstrap */}}

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# Control plane provider
22
{{- 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 }}
3+
{{- range $controlPlane := .Values.controlPlane }}
4+
{{- $controlPlaneNamespace := default ( printf "%s-%s" $controlPlane.name "control-plane-system" ) $controlPlane.namespace }}
5+
{{- $controlPlaneName := $controlPlane.name }}
6+
{{- $controlPlaneVersion := $controlPlane.version }}
247
---
258
apiVersion: v1
269
kind: Namespace
@@ -51,5 +34,5 @@ spec:
5134
namespace: {{ $.Values.configSecret.namespace }}
5235
{{- end }}
5336
{{- end }}
54-
{{- end }} {{/* range $controlPlane := $controlPlanes */}}
37+
{{- end }} {{/* range $controlPlane := .Values.controlPlane */}}
5538
{{- end }} {{/* if .Values.controlPlane */}}

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
# Core provider
22
{{- 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 }}
3+
{{- $coreNamespace := default ( printf "%s-%s" .Values.core.name "capi-system" ) .Values.core.namespace }}
4+
{{- $coreName := .Values.core.name }}
5+
{{- $coreVersion := .Values.core.version }}
236
---
247
apiVersion: v1
258
kind: Namespace

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# Infrastructure providers
22
{{- 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 }}
3+
{{- range $infra := .Values.infrastructure }}
4+
{{- $infrastructureNamespace := default ( printf "%s-%s" $infra.name "infrastructure-system" ) $infra.namespace }}
5+
{{- $infrastructureName := $infra.name }}
6+
{{- $infrastructureVersion := $infra.version }}
247
---
258
apiVersion: v1
269
kind: Namespace
@@ -69,5 +52,5 @@ spec:
6952
{{- if $.Values.additionalDeployments }}
7053
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
7154
{{- end }}
72-
{{- end }} {{/* range $infrastructure := $infrastructures */}}
55+
{{- end }} {{/* range $infra := .Values.infrastructure */}}
7356
{{- end }} {{/* if .Values.infrastructure */}}

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
---
22
# ---
33
# Cluster API provider options
4-
core: ""
5-
bootstrap: ""
6-
controlPlane: ""
7-
infrastructure: ""
8-
addon: ""
4+
core:
5+
name: ""
6+
# namespace: "" # Optional
7+
# version: "" # Optional
8+
bootstrap:
9+
- name: ""
10+
# namespace: "" # Optional
11+
# version: "" # Optional
12+
controlPlane:
13+
- name: ""
14+
# namespace: "" # Optional
15+
# version: "" # Optional
16+
infrastructure:
17+
- name: ""
18+
# namespace: "" # Optional
19+
# version: "" # Optional
20+
addon:
21+
- name: ""
22+
# namespace: "" # Optional
23+
# version: "" # Optional
924
manager.featureGates: {}
1025
# ---
1126
# Common configuration secret options

0 commit comments

Comments
 (0)