What do `ternary`, `coalesce` and `empty` do?
BeginnerConceptTemplating: Go Templates & Sprig
Answer
pullPolicy: {{ ternary "Always" "IfNotPresent" .Values.dev | quote }} # true-value false-value condition
registry: {{ coalesce .Values.image.registry .Values.global.imageRegistry "docker.io" }} # first non-empty
{{- if empty .Values.api.extraEnv }}# nothing to add{{ end }}
coalesce is the cleanest way to implement "local value, else global value, else default" in subchart-friendly charts.
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