audit code for mergeOverwrite cases that would require use of deepCopy
We merged !1052 (merged) to fix #668 (closed) and we realized that the same issue may be present elsewhere in our code.
we realized some time ago that mergeOverwrite in many cases needs to be used with deepcopy (I had discussed this with you months ago, but before understanding what was actually going on)
dict_1:
x: dummy
dict_2:
b:
c: 43
dict_3:
b:
c: 44
mergeOverwrite $dict_1 $dict_2 $dict_3
... will result in dict_1 having 44 as the values (which is what we want), but will also result in having dict_2 with 44 -- which is most likely not our intention
the reason is that (and the Helm doc says it clearly) mergeOverwrite is " not a deep copy operation" (https://helm.sh/docs/chart_template_guide/function_list/#mergeoverwrite-mustmergeoverwrite)
since it does not do a deepCopy of dict_2, when it merges dict_2 into dict_1, the dict_1.b is set to dict_2.b, and when dict_3 is then merged into dict_1, dict_1.b.c is set to 44, but dict_1.b being == to dict_2.b, dict_2.b is also modified
It would be wise to always use deepCopy
on all "source" arguments of mergeOverwrite (mergeOverwrite dest source1 source2 source3 ...
).
An exception to this "rule" can be made in obviously non-problematic cases like mergeOverwrite $x (dict "a "b") $y
: in such a case we don't mind if the dict "a" "b"
is modified because nothing will read it afterwards, since no variable is bound to it.