Skip to content

Commit

Permalink
Add deployment overrides to templates files
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Aplatony <[email protected]>
  • Loading branch information
omerap12 committed Jul 30, 2024
1 parent 2e244f4 commit a51d44e
Show file tree
Hide file tree
Showing 9 changed files with 1,613 additions and 2 deletions.
3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ spec:
secretNamespace: {{ $.Values.secretNamespace }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "addon" }}
{{ .Values.deploymentOverride.addon | toYaml | nindent 2 }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "bootstrap" }}
{{ .Values.deploymentOverride.bootstrap | toYaml | nindent 2 }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions hack/charts/cluster-api-operator/templates/control-plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "controlPlane" }}
{{ .Values.deploymentOverride.controlPlane | toYaml | nindent 2 }}
{{- end }}
{{- end }}

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "coreCondition" }}
{{ .Values.deploymentOverride.coreCondition| toYaml | nindent 2 }}
{{- end }}

{{- end }}
3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "core" }}
{{ .Values.deploymentOverride.core | toYaml | nindent 2 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ spec:
{{- end }}
{{- end }}
{{- end }}

{{- if hasKey $.Values.deploymentOverride "infraCondition" }}
{{ .Values.deploymentOverride.infraCondition | toYaml | nindent 2 }}
{{- end }}
{{- end }}

3 changes: 3 additions & 0 deletions hack/charts/cluster-api-operator/templates/infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey $.Values.deploymentOverride "infrastructure" }}
{{ .Values.deploymentOverride.infrastructure | toYaml | nindent 2 }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,33 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(Equal(string(expectedManifests)))
})

It("should include deplpoymentoverrides when specified - all", func() {
manifest, err := helmChart.Run(map[string]string{
"core": "override-test-core",
"bootstrap": "override-test-core",
"controlPlane": "override-test-core",
"infrastructure": "override-test-core",
"addon": "override-test-core",
"deploymentOverride.addon.containers[0].name": "manager",
"deploymentOverride.addon.containers[0].imageUrl": "test.org/cluster-api-provider-aws/cluster-api-provider-aws-controller:v0.6.0",
"deploymentOverride.core.containers[0].name": "manager",
"deploymentOverride.core.containers[0].imageUrl": "test.org/cluster-api/cluster-api-controller:v1.7.1",
"deploymentOverride.infrastructure.deployment.containers[0].name": "manager",
"deploymentOverride.infrastructure.deployment.containers[0].imageUrl": "test.org/cluster-api-vsphere/cluster-api-vsphere-controller:v1.10.0",
"deploymentOverride.bootstrap.deployment.containers[0].name": "manager",
"deploymentOverride.bootstrap.deployment.containers[0].imageUrl": "test.org/cluster-api-bootstrap-provider-kubeadm/cluster-api-kubeadm-controller:v0.4.0",
"deploymentOverride.controlPlane.deployment.containers[0].name": "manager",
"deploymentOverride.controlPlane.deployment.containers[0].imageUrl": "test.org/cluster-api-control-plane/cluster-api-control-plane-controller:v0.4.0",
"deploymentOverride.coreConditions.containers[0].name": "manager",
"deploymentOverride.coreConditions.containers[0].imageUrl": "test.org/cluster-api/cluster-api-controller:v1.7.1",
"deploymentOverride.infraConditions.containers[0].name": "manager",
"deploymentOverride.infraConditions.containers[0].imageUrl": "test.org/cluster-api/cluster-api-controller:v1.7.1",
})
Except(err).ToNot(HaveOccurred())
Except(manifest).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "deployment-overrides-all.yaml"))
Except(err).ToNot(HaveOccurred())
Except(manifest).To(Equal(string(expectedManifests)))
})
})
Loading

0 comments on commit a51d44e

Please sign in to comment.