Files, Template, and the Root Context
Accessing bundled files and the dot scope.
Files, Template, and the Root Context is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 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.
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.
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 “Files, Template, and the Root Context” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Files, Template, and the Root Context”, 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 “Files, Template, and the Root Context”?
Accessing bundled files and the dot scope. 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 4 of 4.
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 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
- The Values Object and Nested Access
- Release Metadata via .Release
- Chart and Capabilities Objects
- Files, Template, and the Root Context