Truthiness and Operators in Conditions
Using eq, and, or, and not correctly.
Truthiness and Operators in Conditions 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.
Conditions Need Logic
A simple if checks one value, but real charts need richer tests. Helm gives you operators to compare and combine conditions cleanly.
Functions, Not Symbols
Go templates have no == operator. Comparisons are written as functions instead, with the function name first and the values after it.
{{ if eq .Values.env "prod" }}Equality With eq
The eq function returns true when its two arguments are equal. It is the workhorse for matching strings like an environment name.
{{ if eq .Values.tier "gold" }}
priority: high
{{ end }}Its Opposite, ne
Need not-equal? Use ne. It returns true when the two values differ, the mirror image of eq for exclusion checks.
{{ if ne .Values.replicas 0 }}Number Comparisons
For numbers, Helm offers lt, gt, le, and ge: less-than, greater-than, and their or-equal cousins. Each takes two arguments.
{{ if gt .Values.replicas 3 }}Combine With and
The and function is true only when every argument is true. Wrap each sub-check so both must pass before the block renders.
{{ if and .Values.tls .Values.ingress.enabled }}Either One With or
The or function is true if any argument is true. Reach for it when one of several conditions is enough to render the block.
{{ if or .Values.debug .Values.verbose }}Flip It With not
The not function inverts a single value: true becomes false and false becomes true. It reads cleanly for disabled-style flags.
{{ if not .Values.autoscaling.enabled }}
replicas: 1
{{ end }}Empty Means False
Helm treats empty as false: 0, an empty string, nil, and empty lists or maps. The empty function is handy to test that directly.
{{ if not (empty .Values.hosts) }}Group With Parentheses
Because these are functions, nest them with parentheses so Helm evaluates the inner call first and feeds its result outward.
{{ if and (eq .Values.env "prod") .Values.tls }}Many Arguments at Once
and and or are not limited to two inputs. Pass several arguments and Helm checks them all, true only when every one passes for and.
{{ if and .Values.a .Values.b .Values.c }}Quick Check
You need a block to render only when env equals prod.
Recap
You now compare with eq, ne, lt, gt, combine with and, or, not, and group with parentheses. Conditions can express anything now. 🎯
Frequently asked questions
Is the “Truthiness and Operators in Conditions” lesson free?
Yes — the full text of “Truthiness and Operators in Conditions” 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 “Truthiness and Operators in Conditions”?
Using eq, and, or, and not correctly. 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 “Truthiness and Operators in Conditions” 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
- Conditional Blocks with if and else
- Truthiness and Operators in Conditions
- Looping Over Lists and Maps with range
- Scoping a Block with with