default, required, and quote
Providing fallbacks and enforcing mandatory inputs.
default, required, and quote is a free Helm Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Three Everyday Functions
Three functions show up in almost every chart: default for fallbacks, required for must-haves, and quote for safe strings.
Filling Gaps with default
The default function supplies a fallback when a value is empty or missing, so your template never renders a blank.
{{ .Values.replicas | default 1 }}default Argument Order
Written as a function, the fallback comes first and the value second. In a pipe the value arrives last, so it reads naturally.
{{ default "nginx" .Values.image }}What Counts as Empty
For default, empty means 0, an empty string, an empty list, or nil. Any of these triggers the fallback value.
Enforcing Inputs with required
The required function stops rendering with your message when a value is missing, turning silent bugs into clear errors. ⛔
{{ required "image is required" .Values.image }}required Returns the Value
When the value is present, required simply returns it, so you can drop it inline wherever a mandatory field belongs.
host: {{ required "host is required" .Values.host }}Write Helpful Error Messages
A good required message names the missing key and how to set it, so users fix the problem without reading the chart.
Safe Strings with quote
The quote function wraps a value in double quotes, protecting YAML from values that look like numbers, booleans, or nulls.
version: {{ .Values.version | quote }}Why Quoting Matters
Without quote, a value like yes or 1.20 may be parsed as a boolean or number. Quoting keeps it a predictable string.
Combining the Three
These functions compose in one pipeline: supply a default, then quote the result, all in a single readable line.
tag: {{ .Values.tag | default "latest" | quote }}Choosing Between Them
Use default when a value is optional and required when it is mandatory. Reach for quote whenever a string must stay a string.
Quick Check
Which function fails the render when a value is missing?
Recap
You met default for fallbacks, required for mandatory inputs, and quote for safe strings. Together they make values robust. 🎉
Frequently asked questions
Is the “default, required, and quote” lesson free?
Yes — the full text of “default, required, and quote” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.
What will I learn in “default, required, and quote”?
Providing fallbacks and enforcing mandatory inputs. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Helm Academy?
No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “default, required, and quote” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Helm Academy lesson?
Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Piping Values Through Functions
- default, required, and quote
- String Helpers from the Sprig Library
- Encoding with b64enc, toYaml, and indent