DevOps Bootcamp · Lesson

default, required, and quote

Providing fallbacks and enforcing mandatory inputs.

Lesson 2 of 413 steps

default, required, and quote is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

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. 🎉

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “default, required, and quote” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “default, required, and quote”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “default, required, and quote”?

Providing fallbacks and enforcing mandatory inputs. You practise DevOps Bootcamp 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 DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

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 DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp 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

  1. Piping Values Through Functions
  2. default, required, and quote
  3. String Helpers from the Sprig Library
  4. Encoding with b64enc, toYaml, and indent
← Back to DevOps Bootcamp