Interview Prep/Helm/Templating: Go Templates & Sprig

What is `printf` useful for in charts?

BeginnerConceptTemplating: Go Templates & Sprig
Answer

Building strings from parts with Go format verbs:

image: {{ printf "%s/%s:%s" .Values.image.registry .Values.image.repository (.Values.image.tag | default .Chart.AppVersion | toString) | quote }}
url:   {{ printf "postgres://%s@%s-postgres:5432/%s" .Values.db.user .Release.Name .Values.db.name | quote }}

Mixing types breaks %s (a float renders as %!s(float64=1.1)), which is another reason to toString tags.

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig