Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions hack/charts/cluster-api-operator/templates/addon.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# Addon provider
{{- if .Values.addon }}
{{- $addons := split ";" .Values.addon }}
{{- $addonNamespace := "" }}
{{- $addonName := "" }}
{{- $addonVersion := "" }}
{{- range $addon := $addons }}
{{- $addonArgs := split ":" $addon }}
{{- $addonArgsLen := len $addonArgs }}
{{- if eq $addonArgsLen 3 }}
{{- $addonNamespace = $addonArgs._0 }}
{{- $addonName = $addonArgs._1 }}
{{- $addonVersion = $addonArgs._2 }}
{{- else if eq $addonArgsLen 2 }}
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
{{- $addonName = $addonArgs._0 }}
{{- $addonVersion = $addonArgs._1 }}
{{- else if eq $addonArgsLen 1 }}
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
{{- $addonName = $addonArgs._0 }}
{{- else }}
{{- fail "addon provider argument should have the following format helm:v1.0.0 or mynamespace:helm:v1.0.0" }}
{{- end }}
{{- range $name, $addon := $.Values.addon }}
{{- $addonNamespace := default ( printf "%s-%s" $name "addon-system" ) (get $addon "namespace") }}
{{- $addonName := $name }}
{{- $addonVersion := get $addon "version" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- $addonVersion := get $addon "version" }}
{{- $addonVersion := get $addon "version" }}
{{- $addonEnabled := default (get $addon "enabled") true }}
{{- if not $addonEnabled }}
{{- continue }}
{{- end }}

I would have use enabled, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured rangeing over the the dict was sufficient. If the dict is empty no manifests will be created. I can add the enabled check if you prefer though.

Sidenote: Helm does not actually have a continue keyword.

---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -52,5 +34,24 @@ spec:
{{- if $.Values.secretNamespace }}
secretNamespace: {{ $.Values.secretNamespace }}
{{- end }}
{{- if $addon.manifestPatches }}
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
{{- end }}
{{- if $addon.additionalManifests }}
additionalManifests:
name: {{ $addon.additionalManifests.name }}
{{- if $addon.additionalManifests.namespace }}
namespace: {{ $addon.additionalManifests.namespace }}
{{- end }} {{/* if $addon.additionalManifests.namespace */}}
{{- end }}
{{- if $addon.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $addon.additionalManifests.name }}
namespace: {{ default $addonNamespace $addon.additionalManifests.namespace }}
data:
manifests: {{- toYaml $addon.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $name, $addon := .Values.addon */}}
45 changes: 23 additions & 22 deletions hack/charts/cluster-api-operator/templates/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# Bootstrap provider
{{- if .Values.bootstrap }}
{{- $bootstraps := split ";" .Values.bootstrap }}
{{- $bootstrapNamespace := "" }}
{{- $bootstrapName := "" }}
{{- $bootstrapVersion := "" }}
{{- range $bootstrap := $bootstraps }}
{{- $bootstrapArgs := split ":" $bootstrap }}
{{- $bootstrapArgsLen := len $bootstrapArgs }}
{{- if eq $bootstrapArgsLen 3 }}
{{- $bootstrapNamespace = $bootstrapArgs._0 }}
{{- $bootstrapName = $bootstrapArgs._1 }}
{{- $bootstrapVersion = $bootstrapArgs._2 }}
{{- else if eq $bootstrapArgsLen 2 }}
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
{{- $bootstrapName = $bootstrapArgs._0 }}
{{- $bootstrapVersion = $bootstrapArgs._1 }}
{{- else if eq $bootstrapArgsLen 1 }}
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
{{- $bootstrapName = $bootstrapArgs._0 }}
{{- else }}
{{- fail "bootstrap provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
{{- end }}
{{- range $name, $bootstrap := $.Values.bootstrap }}
{{- $bootstrapNamespace := default ( printf "%s-%s" $name "bootstrap-system" ) (get $bootstrap "namespace") }}
{{- $bootstrapName := $name }}
{{- $bootstrapVersion := get $bootstrap "version" }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -51,5 +33,24 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $bootstrap.manifestPatches }}
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}
{{- end }}
{{- if $bootstrap.additionalManifests }}
additionalManifests:
name: {{ $bootstrap.additionalManifests.name }}
{{- if $bootstrap.additionalManifests.namespace }}
namespace: {{ $bootstrap.additionalManifests.namespace }}
{{- end }} {{/* if $bootstrap.additionalManifests.namespace */}}
{{- end }}
{{- if $bootstrap.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $bootstrap.additionalManifests.name }}
namespace: {{ default $bootstrapNamespace $bootstrap.additionalManifests.namespace }}
data:
manifests: {{- toYaml $bootstrap.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $name, $bootstrap := .Values.bootstrap */}}
45 changes: 23 additions & 22 deletions hack/charts/cluster-api-operator/templates/control-plane.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# Control plane provider
{{- if .Values.controlPlane }}
{{- $controlPlanes := split ";" .Values.controlPlane }}
{{- $controlPlaneNamespace := "" }}
{{- $controlPlaneName := "" }}
{{- $controlPlaneVersion := "" }}
{{- range $controlPlane := $controlPlanes }}
{{- $controlPlaneArgs := split ":" $controlPlane }}
{{- $controlPlaneArgsLen := len $controlPlaneArgs }}
{{- if eq $controlPlaneArgsLen 3 }}
{{- $controlPlaneNamespace = $controlPlaneArgs._0 }}
{{- $controlPlaneName = $controlPlaneArgs._1 }}
{{- $controlPlaneVersion = $controlPlaneArgs._2 }}
{{- else if eq $controlPlaneArgsLen 2 }}
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
{{- $controlPlaneName = $controlPlaneArgs._0 }}
{{- $controlPlaneVersion = $controlPlaneArgs._1 }}
{{- else if eq $controlPlaneArgsLen 1 }}
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
{{- $controlPlaneName = $controlPlaneArgs._0 }}
{{- else }}
{{- fail "controlplane provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
{{- end }}
{{- range $name, $controlPlane := $.Values.controlPlane }}
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
{{- $controlPlaneName := $name }}
{{- $controlPlaneVersion := get $controlPlane "version" }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -64,5 +46,24 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $controlPlane.manifestPatches }}
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}
{{- end }}
{{- if $controlPlane.additionalManifests }}
additionalManifests:
name: {{ $controlPlane.additionalManifests.name }}
{{- if $controlPlane.additionalManifests.namespace }}
namespace: {{ $controlPlane.additionalManifests.namespace }}
{{- end }} {{/* if $controlPlane.additionalManifests.namespace */}}
{{- end }}
{{- if $controlPlane.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $controlPlane.additionalManifests.name }}
namespace: {{ default $controlPlaneNamespace $controlPlane.additionalManifests.namespace }}
data:
manifests: {{- toYaml $controlPlane.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $name, $controlPlane := .Values.controlPlane */}}
45 changes: 24 additions & 21 deletions hack/charts/cluster-api-operator/templates/core.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# Core provider
{{- if .Values.core }}
{{- $coreArgs := split ":" .Values.core }}
{{- $coreArgsLen := len $coreArgs }}
{{- $coreVersion := "" }}
{{- $coreNamespace := "" }}
{{- $coreName := "" }}
{{- $coreVersion := "" }}
{{- if eq $coreArgsLen 3 }}
{{- $coreNamespace = $coreArgs._0 }}
{{- $coreName = $coreArgs._1 }}
{{- $coreVersion = $coreArgs._2 }}
{{- else if eq $coreArgsLen 2 }}
{{- $coreNamespace = "capi-system" }}
{{- $coreName = $coreArgs._0 }}
{{- $coreVersion = $coreArgs._1 }}
{{- else if eq $coreArgsLen 1 }}
{{- $coreNamespace = "capi-system" }}
{{- $coreName = $coreArgs._0 }}
{{- else }}
{{- fail "core provider argument should have the following format cluster-api:v1.0.0 or mynamespace:cluster-api:v1.0.0" }}
{{- end }}
{{- range $name, $core := $.Values.core }}
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
{{- $coreName := $name }}
{{- $coreVersion := get $core "version" }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -60,4 +43,24 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $core.manifestPatches }}
manifestPatches: {{ toYaml $core.manifestPatches | nindent 4 }}
{{- end }}
{{- if $core.additionalManifests }}
additionalManifests:
name: {{ $core.additionalManifests.name }}
{{- if $core.additionalManifests.namespace }}
namespace: {{ $core.additionalManifests.namespace }}
{{- end }}
{{- end }}
{{- if $core.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $core.additionalManifests.name }}
namespace: {{ default $coreNamespace $core.additionalManifests.namespace }}
data:
manifests: {{- toYaml $core.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $name, $core := .Values.core */}}
47 changes: 24 additions & 23 deletions hack/charts/cluster-api-operator/templates/infra.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# Infrastructure providers
{{- if .Values.infrastructure }}
{{- $infrastructures := split ";" .Values.infrastructure }}
{{- $infrastructureNamespace := "" }}
{{- $infrastructureName := "" }}
{{- $infrastructureVersion := "" }}
{{- range $infrastructure := $infrastructures }}
{{- $infrastructureArgs := split ":" $infrastructure }}
{{- $infrastructureArgsLen := len $infrastructureArgs }}
{{- if eq $infrastructureArgsLen 3 }}
{{- $infrastructureNamespace = $infrastructureArgs._0 }}
{{- $infrastructureName = $infrastructureArgs._1 }}
{{- $infrastructureVersion = $infrastructureArgs._2 }}
{{- else if eq $infrastructureArgsLen 2 }}
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
{{- $infrastructureName = $infrastructureArgs._0 }}
{{- $infrastructureVersion = $infrastructureArgs._1 }}
{{- else if eq $infrastructureArgsLen 1 }}
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
{{- $infrastructureName = $infrastructureArgs._0 }}
{{- else }}
{{- fail "infrastructure provider argument should have the following format aws:v1.0.0 or mynamespace:aws:v1.0.0" }}
{{- end }}
{{- range $name, $infra := $.Values.infrastructure }}
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
{{- $infrastructureName := $name }}
{{- $infrastructureVersion := get $infra "version" }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -79,5 +61,24 @@ spec:
{{- if $.Values.additionalDeployments }}
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
{{- end }}
{{- if $infra.manifestPatches }}
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
{{- end }} {{/* if $infra.manifestPatches */}}
{{- if $infra.additionalManifests }}
additionalManifests:
name: {{ $infra.additionalManifests.name }}
{{- if $infra.additionalManifests.namespace }}
namespace: {{ $infra.additionalManifests.namespace }}
{{- end }} {{/* if $infra.additionalManifests.namespace */}}
{{- end }} {{/* if $infra.additionalManifests */}}
{{- if $infra.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $infra.additionalManifests.name }}
namespace: {{ default $infrastructureNamespace $infra.additionalManifests.namespace }}
data:
manifests: {{- toYaml $infra.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }}
{{- end }} {{/* range $name, $infra := .Values.infrastructure */}}
45 changes: 23 additions & 22 deletions hack/charts/cluster-api-operator/templates/ipam.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# IPAM providers
{{- if .Values.ipam }}
{{- $ipams := split ";" .Values.ipam }}
{{- $ipamNamespace := "" }}
{{- $ipamName := "" }}
{{- $ipamVersion := "" }}
{{- range $ipam := $ipams }}
{{- $ipamArgs := split ":" $ipam }}
{{- $ipamArgsLen := len $ipamArgs }}
{{- if eq $ipamArgsLen 3 }}
{{- $ipamNamespace = $ipamArgs._0 }}
{{- $ipamName = $ipamArgs._1 }}
{{- $ipamVersion = $ipamArgs._2 }}
{{- else if eq $ipamArgsLen 2 }}
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
{{- $ipamName = $ipamArgs._0 }}
{{- $ipamVersion = $ipamArgs._1 }}
{{- else if eq $ipamArgsLen 1 }}
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
{{- $ipamName = $ipamArgs._0 }}
{{- else }}
{{- fail "ipam provider argument should have the following format in-cluster:v1.0.0 or mynamespace:in-cluster:v1.0.0" }}
{{- end }}
{{- range $name, $ipam := $.Values.ipam }}
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
{{- $ipamName := $name }}
{{- $ipamVersion := get $ipam "version" }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -66,8 +48,27 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $ipam.manifestPatches }}
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}
{{- end }}
{{- if $.Values.additionalDeployments }}
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
{{- end }}
{{- if $ipam.additionalManifests }}
additionalManifests:
name: {{ $ipam.additionalManifests.name }}
{{- if $ipam.additionalManifests.namespace }}
namespace: {{ $ipam.additionalManifests.namespace }}
{{- end }} {{/* if $ipam.additionalManifests.namespace */}}
{{- end }}
{{- if $ipam.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $ipam.additionalManifests.name }}
namespace: {{ default $ipamNamespace $ipam.additionalManifests.namespace }}
data:
manifests: {{- toYaml $ipam.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $name, $ipam := .Values.ipam */}}
47 changes: 47 additions & 0 deletions hack/charts/cluster-api-operator/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"core": {
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
},
"bootstrap": {
"type": "object",
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
},
"controlPlane": {
"type": "object",
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
},
"infrastructure": {
"type": "object",
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
},
"addon": {
"type": "object",
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
},
"ipam": {
"type": "object",
"oneOf": [
{ "type": "object" },
{ "type": "null" }
]
}
}
}
Loading
Loading