What is the difference between `merge` and `mergeOverwrite`?
AdvancedConceptTemplating: Go Templates & Sprig
Answer
Both deep-merge dicts into the first argument (mutating it). merge $dst $src keeps existing keys in $dst and only fills missing ones, so precedence goes to the left. mergeOverwrite $dst $src lets $src overwrite, so precedence goes to the right.
{{- $defaults := dict "replicas" 1 "port" 3000 }}
{{- $final := mergeOverwrite (deepCopy $defaults) .Values.api }}
Lists are replaced, not merged. Always deepCopy the destination when it is part of .Values, otherwise you mutate global state.
More on Templating: Go Templates & Sprig
What template language does Helm use?BeginnerWhat does the dot (`.`) mean in a Helm template?BeginnerWhat is `$` and when do you need it?IntermediateHow does whitespace control (`{{-` and `-}}`) work?BeginnerHow do `if`, `else if` and `else` evaluate truthiness?BeginnerWhat do `and`, `or`, `not`, `eq`, `ne`, `lt`, `gt` look like in Helm?Beginner