Skip to content

Conversation

@mkcp
Copy link
Contributor

@mkcp mkcp commented Nov 14, 2025

Description

Add reference and best practices documentation for package values and templating.

Related Issue

Relates to #3946

Checklist before merging

@mkcp mkcp self-assigned this Nov 14, 2025
@netlify
Copy link

netlify bot commented Nov 14, 2025

Deploy Preview for zarf-docs ready!

Name Link
🔨 Latest commit 0b8a742
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/695ff475545bba00084d0c26
😎 Deploy Preview https://deploy-preview-4368--zarf-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mkcp mkcp added the documentation 📘 Improvements or additions to documentation label Nov 14, 2025
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 52 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mkcp added 2 commits November 14, 2025 12:52
…em rather than duplicating the same content

Signed-off-by: Kit Patella <[email protected]>
@mkcp mkcp moved this to In progress in Zarf Nov 14, 2025
mkcp added 5 commits November 14, 2025 12:56
Signed-off-by: Kit Patella <[email protected]>
…nd config file imports and --set-values

Signed-off-by: Kit Patella <[email protected]>
@mkcp mkcp changed the title docs(values,templating): add reference pages for package values and templating docs(values,templating): add reference and best practices pages for package values and templating Nov 14, 2025
@mkcp mkcp changed the title docs(values,templating): add reference and best practices pages for package values and templating docs(values,templating): add reference and best practices pages Nov 14, 2025
@mkcp mkcp marked this pull request as ready for review November 14, 2025 22:13
@mkcp mkcp requested review from a team as code owners November 14, 2025 22:13
a1994sc
a1994sc previously approved these changes Nov 14, 2025
Copy link
Contributor

@a1994sc a1994sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkcp mkcp added this pull request to the merge queue Nov 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 14, 2025

See the [Templating Reference](/ref/templating/) for complete function documentation.

## Avoid Sensitive Data in Values Files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this is good advice but I do think it is worth calling out that values files will be the primary mechanism for orchestrating sensitive values. Given the declarative delivery model - all secrets have to originate from somewhere.

It will be important for sunsetting zarf variables as it will provide a way to break these out of zarf config files.

We may want to delineate between sensitive values defaults getting "baked" into the package - for which you had a few good examples of different environment overrides that would align to that story telling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good callout - I rewrote this section to highlight not committing secrets to package defaults, and gave examples of how they can be passed in.


## Common Errors and Solutions

### Template Parse Errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ I like that we are making errors in docs discoverable.


:::

Zarf supports Go template syntax and `text/template` engine with powerful features including control flow and functions. Zarf includes the full library of [Sprig functions](http://masterminds.github.io/sprig/) and some builtins for dynamic configuration in manifests, files, and actions. This powerful templating system enables complex transformations, conditional logic, and data manipulation beyond simple string substitution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a good place to identify what is different between zarf templating and helm templating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some notes about the similarities and differences here

Copy link
Member

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving comments on the review so far, I'll aim to do a review on the ref section at another point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Across this PR we reference zarf package inspect, zarf dev inspect and using the values schema however none of these features are merged into Zarf as of yet. IMO we should wait until a feature is merged before documenting it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this is addressed now


## Provide Defaults for Optional Values

Use the `default` function to provide fallback values:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While defaults are generally a good practice, I don't think they really make sense in the context of Zarf since we always validate that there is a value for template. I could be missing scenarios but AFAIK there is no way for the default to come into play

Comment on lines 227 to 237
data:
# Numbers must be strings in ConfigMaps
port: {{ .Values.app.port | toString | quote }}
replicas: {{ .Values.app.replicas | toString | quote }}

# Booleans to strings
debug: {{ .Values.app.debug | toString | quote }}

# ❌ RISKY: Type mismatch errors
data:
port: {{ .Values.app.port }} # May fail if port is a number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numbers don't have to be strings in configmaps, Kubernetes will store either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on generalizing the example a bit then, like "explicit type conversion may be necessary?"


## Handle Missing Values Gracefully

Protect against missing or nil values:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this advice makes sense in the context of Zarf, the "good" example will still fail if .values.monitoring.enabled is not set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I don't like encouraging conditional blocks like this either. Removed in latest

@mkcp mkcp moved this from In progress to Next in Zarf Dec 2, 2025
@brandtkeller brandtkeller added this to the v0.67.1 Release milestone Dec 4, 2025
@mkcp mkcp moved this from Next to PR Review in Zarf Jan 8, 2026
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments as I iterate through some tests - otherwise I like how clean and comprehensive this is.


## Do Not Commit Sensitive Values in Package

Values are the best way to pass secrets into your Zarf package, but those secrets should not be baked into the values files a package is created with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++


:::

Package Values provide a familiar way to define and reusable configuration data in your Zarf packages. Unlike the legacy [Variables and Constants](/ref/values/) system that uses string substitution with `###ZARF_VAR_###` syntax, Package Values uses Go templates with access to structured data and types, [go's templating engine](https://pkg.go.dev/text/template), and custom functions like those offered by [Sprig](/ref/templating/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammatical item:

a familiar way to define and reusable configuration data

- `name`: The path where the value should be stored (e.g., `database.password`)
- `type`: The format of the output - `string` (default), `json`, or `yaml`

Values set via `setValues` are available in subsequent actions and manifests within the same deployment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a note in-passing that an example here may be valuable (is that a pun?) - will resolve if included elsewhere.

order: 10
---

This guide provides best practices for using [Package Values](/ref/package-values/) in your Zarf packages.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's briefly touched on in the ref document - but If I think of the ref document as the "how" and best practices as the "why" - I wonder if a good addition here could be the mention of why the use of granular sourcePath/targetPath. Security considerations and treating it as an allow list as well as traceability when we think about potential collisions with on-deployment values files and the future of imports.

--features="values=true" \
-f custom-values.yaml

# Multiple values files (later files override earlier ones)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the shorthand for this flag -v? (doesn't exist in dev deploy yet but -f is used already in dev deploy)

@github-project-automation github-project-automation bot moved this from PR Review to In progress in Zarf Jan 9, 2026

## Using Helm charts within Zarf:
- Helm templating happens inside chart templates (standard Helm behavior)
- Zarf templating happens at the package level
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence Zarf templating happens a the package level, feels like it doesn't quite fit. In the flow of deploying a Helm chart, Zarf templating never happens, instead we forward values to the Helm chart for templating to occur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📘 Improvements or additions to documentation

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

5 participants