Pipelines
Pipelines chain values through functions with the | operator, just like a Unix shell pipe.
{{ value | func1 | func2 }}A pipeline sends the result of one expression into a function using |. The value on the left becomes the last argument of the function on the right.
Why pipelines
They read left-to-right and let you compose transformations cleanly instead of nesting function calls.
{{ .Values.name | upper | quote }}Here .Values.name is uppercased, then wrapped in quotes.
Equivalent forms
{{ quote .Values.name }} and {{ .Values.name | quote }} do the same thing; the pipeline form scales better as you add steps.
Example
data:
# Uppercase then quote
name: {{ .Values.appName | upper | quote }}
# Default value, then quote
tier: {{ .Values.tier | default "backend" | quote }}
# Trim whitespace and lowercase
slug: {{ .Values.slug | trim | lower | quote }}When to use it
- A chart author pipes a value through upper | quote to ensure an environment variable is always uppercase and correctly quoted in the resulting YAML.
- A template pipes a potentially empty value through default so the chart renders a sensible fallback rather than empty YAML keys.
- A developer pipes a multi-line string through nindent 4 to correctly align a block of text embedded in a YAML manifest without counting spaces manually.
More examples
Chain quote and upper
Chains two Sprig string functions via pipes: upper converts to uppercase, then quote wraps the result in YAML double quotes.
env:
- name: APP_ENV
value: {{ .Values.environment | upper | quote }}
- name: LOG_LEVEL
value: {{ .Values.logLevel | lower | quote }}Default value in pipeline
Pipes each value through default to provide a fallback, so the chart works even if the operator omits those keys.
# Use a default if the value is not set
image: {{ .Values.image.repository | default "nginx" }}:{{ .Values.image.tag | default "latest" }}Indent a block value
Converts a values map to YAML with toYaml, then indents it by 4 spaces with nindent so it sits correctly under the data key.
data:
config.yaml: |
{{- .Values.appConfig | toYaml | nindent 4 }}
Discussion