Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quote to podAnnotation templating #678

Merged
merged 1 commit into from
Oct 2, 2023
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
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
Loading