Skip to content

Commit

Permalink
Add quote to podAnnotation templating (#678)
Browse files Browse the repository at this point in the history
Co-authored-by: Yevhen Ivantsov <[email protected]>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Oct 2, 2023
1 parent 64f01c3 commit f996d9e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/charts/bamboo-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bamboo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/confluence/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/crowd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/jira/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
5 changes: 5 additions & 0 deletions src/test/config/kind/common-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions src/test/java/test/PodAnnotationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ 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");

assertThat(annotations).isObject(Map.of(
"podAnnotation1", "podOfHumpbacks",
"podAnnotation2", "podOfOrcas",
"podAnnotation3", b64enc("podOfTucuxis")
"podAnnotation3", "'" + b64enc("podOfTucuxis") + "'",
"podAnnotation4", "'PODOFTUCUXIS'"
));
}

Expand All @@ -43,15 +46,17 @@ 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");

assertThat(annotations).isObject(Map.of(
"podAnnotation1", "podOfHumpbacks",
"podAnnotation2", "podOfOrcas",
"podAnnotation3", b64enc("podOfTucuxis")
"podAnnotation3", "'" + b64enc("podOfTucuxis") + "'",
"podAnnotation4", "'PODOFTUCUXIS'"
));
}

Expand Down

0 comments on commit f996d9e

Please sign in to comment.