Search code examples
gosyntaxyamlkubernetes-helm

What is the purpose of {{ . }} in YAML?


I know that {{ }} is used to evaluate expressions. But what does specifically {{ . }} mean in Helm charts?

Example:

imagePullSecrets:
      {{- range .Values.image.pullSecrets }}
        - name: {{ . }}

Solution

  • Your question is not about YAML, it is about Go templates.

    In Go templates, {{ }} evaluates expressions and . is the reference to the cursor. In your example, the cursor is set by range, which evaluates its body for each element in pullSecrets, and in each evaluation the cursor is set to the current element.

    Helm uses Go templates to preprocess YAML input. This has nothing to do with YAML itself.