What is `$` and when do you need it?
IntermediateConceptTemplating: Go Templates & Sprig
Answer
$ is always bound to the root context passed to the template, no matter how deeply with/range changed .. You need it to reach .Release or .Values from inside a loop:
{{- range .Values.api.extraEnv }}
- name: {{ .name }}
value: {{ .value | quote }}
- name: {{ .name }}_RELEASE
value: {{ $.Release.Name }}
{{- end }}
Writing .Release.Name inside the range fails with can't evaluate field Release in type map[string]interface {}.
More on Templating: Go Templates & Sprig
What template language does Helm use?BeginnerWhat does the dot (`.`) mean in a Helm template?BeginnerHow 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?BeginnerHow does `with` work, and what is its common pitfall?Intermediate