Files, Template, and the Root Context
Accessing bundled files and the dot scope.
Files, Template, and the Root Context is a free Helm Academy lesson on CoddyKit — lesson 4 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.
The Root Context: The Dot
At the top of a template, the dot . is the root context holding every built-in object: .Values, .Release, .Chart, and more.
Dot Can Change Scope
Blocks like with and range rebind the dot to a narrower value. So . does not always mean the root inside every block.
Reaching Root With Dollar
The variable $ always points at the original root context. Inside a range or with, use $ to get back to .Values or .Release.
{{ range .Values.ports }}
release: {{ $.Release.Name }}
{{ end }}The Files Object
.Files lets templates read non-template files bundled in the chart, such as a config file you want to ship inside a ConfigMap. 📄
Reading a File as Text
.Files.Get returns a file's contents as a string. Pass the path relative to the chart root to pull it into your manifest.
data:
app.conf: |
{{ .Files.Get "config/app.conf" | indent 4 }}Files Has Limits
.Files cannot read everything: templates/ and Chart.yaml are excluded, and .helmignore patterns are skipped during packaging.
Globbing Multiple Files
.Files.Glob matches several files by pattern, returning a map you can range over to build many ConfigMap entries at once.
{{ range $path, $bytes := .Files.Glob "config/*" }}...{{ end }}Encoding File Contents
Binary or secret data should be base64 encoded. Chain .Files.Get with b64enc to embed it safely in a Secret resource.
ca.crt: {{ .Files.Get "certs/ca.crt" | b64enc }}The Template Object
The .Template object describes the file being rendered. .Template.Name is its path, useful in comments and error messages.
# rendered from {{ .Template.Name }}BasePath Points at templates
.Template.BasePath gives the templates directory path of the chart being rendered. It pairs with .Template.Name to locate yourself.
Passing Root Into Helpers
Named templates only see the context you hand them. Passing $ or the root dot ensures a helper can still reach .Values and .Release.
{{ include "mychart.labels" $ }}Quick Check
You are inside a range loop where the dot has been rebound to a list item.
Recap: Files and Root Context
You learned the dot is the root context, $ always reaches it, and .Files plus .Template let you embed bundled files and locate the current template.
Frequently asked questions
Is the “Files, Template, and the Root Context” lesson free?
Yes — the full text of “Files, Template, and the Root Context” 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 “Files, Template, and the Root Context”?
Accessing bundled files and the dot scope. 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 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Files, Template, and the Root Context” 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
- The Values Object and Nested Access
- Release Metadata via .Release
- Chart and Capabilities Objects
- Files, Template, and the Root Context