From 2df03d3a326d42a9718d273c711cdbeb478bdb1c Mon Sep 17 00:00:00 2001 From: chengli3 Date: Fri, 22 Feb 2019 19:28:52 +0800 Subject: [PATCH] Deep copy daemonset_yaml cross loop In templates/utils/_daemonset_overrides.tpl, $context.Values.__daemonset_yaml is used cross the loop. It is not deep copied in each round of loop. It means that the property set in the previous round of loop will still exist in current loop. This is not expected. This patch is to make a deep copy in each round of loop. Change-Id: I4e610e4acf67d92257f9d254546ec0b5b31609fe --- helm-toolkit/templates/utils/_daemonset_overrides.tpl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/helm-toolkit/templates/utils/_daemonset_overrides.tpl b/helm-toolkit/templates/utils/_daemonset_overrides.tpl index 302fcff0d..f36a856a2 100644 --- a/helm-toolkit/templates/utils/_daemonset_overrides.tpl +++ b/helm-toolkit/templates/utils/_daemonset_overrides.tpl @@ -21,7 +21,6 @@ limitations under the License. {{- $configmap_name := index . 3 }} {{- $context := index . 4 }} {{- $_ := unset $context ".Files" }} - {{- $_ := set $context.Values "__daemonset_yaml" $daemonset_yaml }} {{- $daemonset_root_name := printf (print $context.Chart.Name "_" $daemonset) }} {{- $_ := set $context.Values "__daemonset_list" list }} {{- $_ := set $context.Values "__default" dict }} @@ -194,12 +193,13 @@ limitations under the License. {{- $list_aggregate := append $context.Values.__daemonset_list $context.Values.__default }} {{- $_ := set $context.Values "__daemonset_list" $list_aggregate }} - {{- $_ := set $context.Values "__last_configmap_name" $configmap_name }} {{- range $current_dict := $context.Values.__daemonset_list }} {{- $context_novalues := omit $context "Values" }} {{- $merged_dict := merge $current_dict.nodeData $context_novalues }} {{- $_ := set $current_dict "nodeData" $merged_dict }} + {{/* Deep copy original daemonset_yaml */}} + {{- $_ := set $context.Values "__daemonset_yaml" ($daemonset_yaml | toYaml | fromYaml) }} {{/* name needs to be a DNS-1123 compliant name. Ensure lower case */}} {{- $name_format1 := printf (print $daemonset_root_name "-" $current_dict.name) | lower }} @@ -235,7 +235,7 @@ limitations under the License. {{- range $current_volume := $context.Values.__daemonset_yaml.spec.template.spec.volumes }} {{- $_ := set $context.Values "__volume" $current_volume }} {{- if hasKey $context.Values.__volume "secret" }} - {{- if eq $context.Values.__volume.secret.secretName $context.Values.__last_configmap_name }} + {{- if eq $context.Values.__volume.secret.secretName $configmap_name }} {{- $_ := set $context.Values.__volume.secret "secretName" $current_dict.dns_1123_name }} {{- end }} {{- end }} @@ -272,6 +272,5 @@ limitations under the License. {{/* generate daemonset yaml */}} --- {{ $context.Values.__daemonset_yaml | toYaml }} - {{- $_ := set $context.Values "__last_configmap_name" $current_dict.dns_1123_name }} {{- end }} {{- end }}