Interview Prep/Helm/Chart Structure & Metadata

How does the standard `fullname` helper work and why is it so convoluted?

IntermediateConceptChart Structure & Metadata
Answer
{{- define "shop.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

It lets users force an exact name (fullnameOverride), avoids stutter like shop-shop when the release name already contains the chart name, and stays within the 63-character DNS label limit without a trailing hyphen.

All Helm questions Roadmap: Helm

More on Chart Structure & Metadata