From d9c155c9be16bead477f1e97219e65ad74fb304a Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Wed, 27 Sep 2023 05:31:53 +1000 Subject: [PATCH] Add quote to podAnnotation templating --- src/main/charts/bamboo-agent/templates/_helpers.tpl | 2 +- src/main/charts/bamboo/templates/_helpers.tpl | 2 +- src/main/charts/bitbucket/templates/_helpers.tpl | 2 +- src/main/charts/confluence/templates/_helpers.tpl | 2 +- src/main/charts/crowd/templates/_helpers.tpl | 2 +- src/main/charts/jira/templates/_helpers.tpl | 2 +- src/test/config/kind/common-values.yaml | 5 +++++ src/test/java/test/PodAnnotationsTest.java | 13 +++++++++---- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/charts/bamboo-agent/templates/_helpers.tpl b/src/main/charts/bamboo-agent/templates/_helpers.tpl index d2b0dd38a..ae0b105cf 100644 --- a/src/main/charts/bamboo-agent/templates/_helpers.tpl +++ b/src/main/charts/bamboo-agent/templates/_helpers.tpl @@ -57,7 +57,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "agent.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/main/charts/bamboo/templates/_helpers.tpl b/src/main/charts/bamboo/templates/_helpers.tpl index 92a5d7ebf..4130cae09 100644 --- a/src/main/charts/bamboo/templates/_helpers.tpl +++ b/src/main/charts/bamboo/templates/_helpers.tpl @@ -122,7 +122,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "bamboo.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/main/charts/bitbucket/templates/_helpers.tpl b/src/main/charts/bitbucket/templates/_helpers.tpl index 168a6dfcd..7777c3288 100644 --- a/src/main/charts/bitbucket/templates/_helpers.tpl +++ b/src/main/charts/bitbucket/templates/_helpers.tpl @@ -130,7 +130,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "bitbucket.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/main/charts/confluence/templates/_helpers.tpl b/src/main/charts/confluence/templates/_helpers.tpl index 49f180f03..a0a708e2f 100644 --- a/src/main/charts/confluence/templates/_helpers.tpl +++ b/src/main/charts/confluence/templates/_helpers.tpl @@ -277,7 +277,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "confluence.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/main/charts/crowd/templates/_helpers.tpl b/src/main/charts/crowd/templates/_helpers.tpl index b4c202494..4d80c0e32 100644 --- a/src/main/charts/crowd/templates/_helpers.tpl +++ b/src/main/charts/crowd/templates/_helpers.tpl @@ -122,7 +122,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "crowd.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/main/charts/jira/templates/_helpers.tpl b/src/main/charts/jira/templates/_helpers.tpl index 794c3a27d..55d11ffd8 100644 --- a/src/main/charts/jira/templates/_helpers.tpl +++ b/src/main/charts/jira/templates/_helpers.tpl @@ -122,7 +122,7 @@ Define pod annotations here to allow template overrides when used as a sub chart */}} {{- define "jira.podAnnotations" -}} {{- range $key, $value := .Values.podAnnotations }} -{{ $key }}: {{ tpl $value $ }} +{{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} diff --git a/src/test/config/kind/common-values.yaml b/src/test/config/kind/common-values.yaml index 337715623..64894840a 100644 --- a/src/test/config/kind/common-values.yaml +++ b/src/test/config/kind/common-values.yaml @@ -44,6 +44,11 @@ volumes: # this is the default storageclass name created when deploying the provisioner storageClassName: nfs-client +podAnnotations: + annotation: "{{ \"podOfTucuxis\" | upper }}" + quote: "true" + normal: annotation-comes-here + # KinD is deployed with custom settings, namely extraPortMappings for ports 80 and 443 # to make sure ingress traffic is available at http://localhost ingress: diff --git a/src/test/java/test/PodAnnotationsTest.java b/src/test/java/test/PodAnnotationsTest.java index 689d78f93..18c985cf4 100644 --- a/src/test/java/test/PodAnnotationsTest.java +++ b/src/test/java/test/PodAnnotationsTest.java @@ -25,7 +25,9 @@ void pod_annotations(Product product) throws Exception { final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( "podAnnotations.podAnnotation1", "podOfHumpbacks", "podAnnotations.podAnnotation2", "podOfOrcas", - "podAnnotations.podAnnotation3", "'{{ \"podOfTucuxis\" | b64enc }}'" + "podAnnotations.podAnnotation3", "'{{ \"podOfTucuxis\" | b64enc }}'", + "podAnnotations.podAnnotation4", "'{{ \"podOfTucuxis\" | upper }}'" + )); final var annotations = resources.getStatefulSet(product.getHelmReleaseName()).getPodMetadata().get("annotations"); @@ -33,7 +35,8 @@ void pod_annotations(Product product) throws Exception { assertThat(annotations).isObject(Map.of( "podAnnotation1", "podOfHumpbacks", "podAnnotation2", "podOfOrcas", - "podAnnotation3", b64enc("podOfTucuxis") + "podAnnotation3", "'" + b64enc("podOfTucuxis") + "'", + "podAnnotation4", "'PODOFTUCUXIS'" )); } @@ -43,7 +46,8 @@ void bamboo_agent_pod_annotations(Product product) throws Exception { final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( "podAnnotations.podAnnotation1", "podOfHumpbacks", "podAnnotations.podAnnotation2", "podOfOrcas", - "podAnnotations.podAnnotation3", "'{{ \"podOfTucuxis\" | b64enc }}'" + "podAnnotations.podAnnotation3", "'{{ \"podOfTucuxis\" | b64enc }}'", + "podAnnotations.podAnnotation4", "'{{ \"podOfTucuxis\" | upper }}'" )); final var annotations = resources.getDeployment(product.getHelmReleaseName()).getPodMetadata().get("annotations"); @@ -51,7 +55,8 @@ void bamboo_agent_pod_annotations(Product product) throws Exception { assertThat(annotations).isObject(Map.of( "podAnnotation1", "podOfHumpbacks", "podAnnotation2", "podOfOrcas", - "podAnnotation3", b64enc("podOfTucuxis") + "podAnnotation3", "'" + b64enc("podOfTucuxis") + "'", + "podAnnotation4", "'PODOFTUCUXIS'" )); }