Interview Prep/Helm/Templating: Go Templates & Sprig

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.

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig