From eb27e406014cf8e766beb22092f22d97a38cb1da Mon Sep 17 00:00:00 2001 From: Mark Hofmeijer Date: Mon, 14 Oct 2024 15:50:45 +0200 Subject: [PATCH 1/3] Print annotation and label value as YAML to support array string values --- charts/temporal/templates/_helpers.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/temporal/templates/_helpers.tpl b/charts/temporal/templates/_helpers.tpl index 4ff707d7..a4608ea6 100644 --- a/charts/temporal/templates/_helpers.tpl +++ b/charts/temporal/templates/_helpers.tpl @@ -91,11 +91,11 @@ Create the annotations for all resources {{- end -}} {{- $resourceAnnotations := merge $scopeAnnotations $componentAnnotations -}} {{- range $annotation_name, $annotation_value := $resourceAnnotations }} -{{ $annotation_name }}: {{ $annotation_value }} +{{ $annotation_name }}: {{ $annotation_value | toYaml }} {{- end -}} {{- end -}} {{- range $annotation_name, $annotation_value := $global.Values.additionalAnnotations }} -{{ $annotation_name }}: {{ $annotation_value }} +{{ $annotation_name }}: {{ $annotation_value | toYaml }} {{- end -}} {{- end -}} @@ -128,11 +128,11 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }} {{- end -}} {{- $resourceLabels := merge $scopeLabels $componentLabels -}} {{- range $label_name, $label_value := $resourceLabels }} -{{ $label_name}}: {{ $label_value }} +{{ $label_name}}: {{ $label_value | toYaml }} {{- end -}} {{- end -}} {{- range $label_name, $label_value := $global.Values.additionalLabels }} -{{ $label_name }}: {{ $label_value }} +{{ $label_name }}: {{ $label_value | toYaml }} {{- end -}} {{- end -}} From 92d6ca6e9c88cbe158940cbc7e250615cd5e2f74 Mon Sep 17 00:00:00 2001 From: Mark Hofmeijer Date: Mon, 14 Oct 2024 16:13:45 +0200 Subject: [PATCH 2/3] Add automated tests --- charts/temporal/tests/deployment_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charts/temporal/tests/deployment_test.go b/charts/temporal/tests/deployment_test.go index 6364f1d5..94ff6778 100644 --- a/charts/temporal/tests/deployment_test.go +++ b/charts/temporal/tests/deployment_test.go @@ -120,6 +120,7 @@ func TestTemplateServerDeploymentAnnotations(t *testing.T) { SetValues: map[string]string{ "server.frontend.deploymentAnnotations.one": "three", "server.frontend.deploymentAnnotations.four": "four", + "server.frontend.deploymentAnnotations.five": "[{\"test\":\"success\"}]", "server.deploymentAnnotations.one": "one", "server.deploymentAnnotations.two": "two", "additionalAnnotations.zero": "zero", @@ -135,6 +136,7 @@ func TestTemplateServerDeploymentAnnotations(t *testing.T) { require.Equal(t, "three", deployment.ObjectMeta.Annotations["one"]) require.Equal(t, "two", deployment.ObjectMeta.Annotations["two"]) require.Equal(t, "four", deployment.ObjectMeta.Annotations["four"]) + require.Equal(t, "[{\"test\":\"success\"}]", deployment.ObjectMeta.Annotations["five"]) require.Equal(t, "zero", deployment.ObjectMeta.Annotations["zero"]) require.Equal(t, "zero", deployment.Spec.Template.ObjectMeta.Annotations["zero"]) } @@ -154,6 +156,7 @@ func TestTemplateServerDeploymentLabels(t *testing.T) { SetValues: map[string]string{ "server.frontend.deploymentLabels.one": "three", "server.frontend.deploymentLabels.four": "four", + "server.frontend.deploymentLabels.five": "[{\"test\":\"success\"}]", "server.deploymentLabels.one": "one", "server.deploymentLabels.two": "two", "additionalLabels.zero": "zero", @@ -169,6 +172,7 @@ func TestTemplateServerDeploymentLabels(t *testing.T) { require.Equal(t, "three", deployment.ObjectMeta.Labels["one"]) require.Equal(t, "two", deployment.ObjectMeta.Labels["two"]) require.Equal(t, "four", deployment.ObjectMeta.Labels["four"]) + require.Equal(t, "[{\"test\":\"success\"}]", deployment.ObjectMeta.Labels["five"]) require.Equal(t, "zero", deployment.ObjectMeta.Labels["zero"]) require.Equal(t, "zero", deployment.Spec.Template.ObjectMeta.Labels["zero"]) } From 667ce226c6a551285e48261d038a08a4895d3eee Mon Sep 17 00:00:00 2001 From: Mark Hofmeijer Date: Wed, 4 Dec 2024 18:50:48 +0100 Subject: [PATCH 3/3] fix: change toTaml to quote because all annotations and labels must be a string at manifest level --- charts/temporal/templates/_helpers.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/temporal/templates/_helpers.tpl b/charts/temporal/templates/_helpers.tpl index a4608ea6..47f0e689 100644 --- a/charts/temporal/templates/_helpers.tpl +++ b/charts/temporal/templates/_helpers.tpl @@ -91,11 +91,11 @@ Create the annotations for all resources {{- end -}} {{- $resourceAnnotations := merge $scopeAnnotations $componentAnnotations -}} {{- range $annotation_name, $annotation_value := $resourceAnnotations }} -{{ $annotation_name }}: {{ $annotation_value | toYaml }} +{{ $annotation_name }}: {{ $annotation_value | quote }} {{- end -}} {{- end -}} {{- range $annotation_name, $annotation_value := $global.Values.additionalAnnotations }} -{{ $annotation_name }}: {{ $annotation_value | toYaml }} +{{ $annotation_name }}: {{ $annotation_value | quote }} {{- end -}} {{- end -}} @@ -128,11 +128,11 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }} {{- end -}} {{- $resourceLabels := merge $scopeLabels $componentLabels -}} {{- range $label_name, $label_value := $resourceLabels }} -{{ $label_name}}: {{ $label_value | toYaml }} +{{ $label_name}}: {{ $label_value | quote }} {{- end -}} {{- end -}} {{- range $label_name, $label_value := $global.Values.additionalLabels }} -{{ $label_name }}: {{ $label_value | toYaml }} +{{ $label_name }}: {{ $label_value | quote }} {{- end -}} {{- end -}}