Interview Prep/Helm/Templating: Go Templates & Sprig

How do `if`, `else if` and `else` evaluate truthiness?

BeginnerConceptTemplating: Go Templates & Sprig
Answer

A pipeline is false if it is false, 0, nil, an empty string, or an empty map, list or slice. Everything else is true.

{{- if .Values.ingress.enabled }}
...
{{- else if .Values.route.enabled }}
...
{{- end }}

Watch for numeric zero: if .Values.replicaCount is false for 0, which may be a legitimate value (scale to zero). Use hasKey or kindIs "invalid" to distinguish "unset" from "zero".

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig