How does `default` work and what is its trap?
IntermediateConceptTemplating: Go Templates & Sprig
Answer
default DEFAULT VALUE returns VALUE unless it is empty, in which case it returns DEFAULT:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Trap: "empty" includes false, 0 and "". default true .Values.enabled always yields true, even when the user set enabled: false. For booleans, use hasKey, ternary, or put the default in values.yaml instead.
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