Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
355d0f5
add feature flag for values
mkcp Aug 28, 2025
a6fb3eb
add internal/values with file validation and parsing and add --value …
mkcp Aug 28, 2025
1d9d728
add value.Values to packager create, deploy, and partially to inpect …
mkcp Aug 28, 2025
3df0a2c
stub out examples and e2e tests
mkcp Aug 28, 2025
4d2c610
rewrite ParseFiles to properly deepmerge values yaml and test it
mkcp Aug 29, 2025
23a8027
update package CLI commands to use ctx ParseFiles
mkcp Aug 29, 2025
b2db2a3
make improvements to value pkg and tests for linting and ctx cancella…
mkcp Aug 29, 2025
eb2453f
make docs-and-schema
mkcp Aug 29, 2025
96eec5d
add values to v1beta1 schema
mkcp Aug 29, 2025
6aeb2cd
convert default internal variables over to values
mkcp Aug 29, 2025
9b9c5ad
undo edits to alpha schema
mkcp Sep 3, 2025
6ab0bc3
testing chart value overrides on v1alpha1, this doesn't get into main
mkcp Sep 3, 2025
3ec1b20
update comments on v1beta1 schema
mkcp Sep 3, 2025
1b76f5b
add values as optional field in packager API and proof of concept hel…
mkcp Sep 3, 2025
2e98fa9
make docs-and-schema
mkcp Sep 3, 2025
f542021
WIP: example chart for zarf values overriding helm values
mkcp Sep 5, 2025
061858d
implement helm overrides in deploy
mkcp Sep 5, 2025
d5fb32d
simplify values example to just a configmap
mkcp Sep 5, 2025
d802aa7
fix bug with everything being stored under a map with emptystring whe…
mkcp Sep 5, 2025
f2cdbca
include package-level value files
mkcp Sep 8, 2025
65e93db
when assembling a package, copy values files that are referenced by URL
mkcp Sep 8, 2025
dd33519
cleanup url handling
mkcp Sep 8, 2025
8bba1af
don't actually handle URLs yet, it affects the current dataflow more …
mkcp Sep 8, 2025
6b6d81e
go templating example, files, manifests, and packageconfig
mkcp Sep 8, 2025
92e1eb7
add setvariables to schema and example declaration, not implemented yet
mkcp Sep 8, 2025
b42120b
update examples to reflect Values go-templating syntax
mkcp Sep 8, 2025
a1dc7ec
add zarf.yaml version to overrides exampel
mkcp Sep 9, 2025
909ab23
fix some rough edges in the templating example
mkcp Sep 9, 2025
9a9c849
working on packagedefinition templating. failing linting for some reason
mkcp Sep 9, 2025
766974c
add templating funcs
mkcp Sep 10, 2025
ba4701e
add repeat templating funct
mkcp Sep 10, 2025
e29a11f
update schema
mkcp Sep 18, 2025
536caa2
iterate on values templating in files/manifests. attempt to import sp…
mkcp Sep 18, 2025
c740a31
update example cases, stub out readmes
mkcp Sep 18, 2025
b5d9a0f
resolve some fixmes
mkcp Sep 24, 2025
2fe95bd
remove package templating for now, and iterate on template objects
mkcp Sep 24, 2025
740749f
clean up some dangling packagetemplating values in examples
mkcp Sep 24, 2025
87259bc
Constants and Variables is handled withing go-templating objects now
mkcp Sep 24, 2025
219b504
update action.Run signature to incorpoate values. Make template objec…
mkcp Sep 24, 2025
a6f467d
update template.Objects flow into actions.Run. build objects as late …
mkcp Sep 24, 2025
7f4228f
add setValues back into examples
mkcp Sep 24, 2025
2b380a3
make docs-and-schema
mkcp Sep 24, 2025
d938db7
update values templates-example
mkcp Sep 24, 2025
4a256ee
apply templates to cmds and enable setValues
mkcp Sep 24, 2025
ceb8cfb
move examples to a directory structure the website can parse. update …
mkcp Sep 24, 2025
ac88a4a
remove create flags from early pkgtemplating. fix some deploy variabl…
mkcp Sep 24, 2025
cc0e2c1
clean up value package and fix a panic from DeepMerge
mkcp Sep 25, 2025
2a3ac66
clean up values-helm-overrides example
mkcp Sep 25, 2025
75e7546
clean up package schema
mkcp Sep 25, 2025
7a7a8c9
more cleanup - fix linter issues
mkcp Sep 25, 2025
07c665e
fix functions in templates, both files and cmds, and produce unit tes…
mkcp Sep 29, 2025
6e02a3e
add README to templating example, add sprig function examples, fix te…
mkcp Sep 29, 2025
234b46d
remove modified-terraform.tf
mkcp Sep 29, 2025
587f7bd
add simple e2e smoke test for values templating
mkcp Sep 29, 2025
8eb1283
revert v1beta1 changes and revert out of scope vars change
mkcp Sep 29, 2025
e1328db
cleanup fixmes
mkcp Sep 29, 2025
79b9075
add yaml and json parsing to setValues
mkcp Sep 29, 2025
9fbb27c
make the linter happy by being less specific about the type of error …
mkcp Sep 29, 2025
57f6a8a
This should fix the setVariables regression - make sure cobra is sett…
mkcp Sep 30, 2025
1d841e0
flag dashes for features in 42 e2e test
mkcp Sep 30, 2025
b25defa
clean up helm-overrides example, accidentally checked in a pkg create…
mkcp Sep 30, 2025
9a37372
true up example/values-templating readme
mkcp Sep 30, 2025
f34bc2e
load pkg.Values.Files relative to the package path not cwd
mkcp Sep 30, 2025
b13eab6
fix values-templating nginx styling
mkcp Sep 30, 2025
8669d72
use relative filename when copying values files dst not absolute path…
mkcp Sep 30, 2025
174e494
fix e2e test, make sure we're templating with the correct key
mkcp Sep 30, 2025
b3f1588
clean up some out-of-scope changes to package inspect manifests and v…
mkcp Oct 1, 2025
23a60c9
Update src/api/v1alpha1/component.go
mkcp Oct 2, 2025
de4a808
make docs-and-schema and don't check an empty ctx
mkcp Oct 2, 2025
2c18659
rename internal/template.ApplyToCmd to Apply and clean up internal/te…
mkcp Oct 2, 2025
ab14746
update e2e values test to check setValues and yaml/json parsing
mkcp Oct 2, 2025
2c53189
don't store the e2e example in json.json.etc and yaml.yaml.etc
mkcp Oct 2, 2025
89de456
helm install broke on dashes, may actually be an action parsing bug
mkcp Oct 2, 2025
3de01ab
clean up assemble.go
mkcp Oct 2, 2025
c48dd07
fix . for sourcePath (extract now returns all values on root path) an…
mkcp Oct 2, 2025
b542964
rework value.Set to handle path to root '.' and add tests. extract an…
mkcp Oct 2, 2025
473c41d
change DeepMerge to a variadic method and add unit tests
mkcp Oct 2, 2025
1f0f715
cleanup and make linter happy
mkcp Oct 2, 2025
1c648b9
bump feature flag version to release version
mkcp Oct 2, 2025
095fbfd
remove extra file-exists check, and make sure we error if not given a…
mkcp Oct 3, 2025
26eed44
rework component file and manifest template field to boolptr with IsT…
mkcp Oct 3, 2025
e062bce
condense examples and remove terraform templating
mkcp Oct 3, 2025
2d77714
ensure relative values.yaml paths don't munge the destination directory
mkcp Oct 3, 2025
d71a493
block values files imports that come from outside the directory
mkcp Oct 3, 2025
4669c88
error if missing key in template. use sprig default func instead
mkcp Oct 6, 2025
2fe037f
fix todos and stub comment
mkcp Oct 6, 2025
ded9820
remove unncessary valuesfile load in packagedefinition
mkcp Oct 7, 2025
f42c346
use local reference to logger.From
mkcp Oct 7, 2025
26b0876
add checks for reserved filenames and directories and ensure package …
mkcp Oct 14, 2025
ba6f9a5
Merge branch 'main' into mkcp/values
mkcp Oct 14, 2025
bcf417c
add values to dev inspect
mkcp Oct 14, 2025
91b3c14
make docs-and-schema
mkcp Oct 14, 2025
83a1f7c
capture os.RemoveAll error and make linter happy
mkcp Oct 14, 2025
862de4d
Merge branch 'main' of github.com:zarf-dev/zarf into mkcp/values-insp…
mkcp Oct 20, 2025
1128221
merge cleanup
mkcp Oct 20, 2025
7810a7d
fix some desync from base branch on merge
mkcp Oct 21, 2025
8ffc674
more merge desync
mkcp Oct 21, 2025
7b1ebff
fix merge desync2
mkcp Oct 21, 2025
7042d4c
move values parsing and flag handling to CLI layer
mkcp Oct 22, 2025
d29718b
update inspect tests and functionality
mkcp Oct 29, 2025
38d61b8
fix cross-platform error message difference and make linter happy
mkcp Oct 29, 2025
f9f9613
don't return var from named return, handled in defer
mkcp Oct 30, 2025
06d6bd4
add inspect to values-templating example and simplify package values …
mkcp Oct 30, 2025
f228644
update tests and make test resources package independent
mkcp Oct 30, 2025
f9a8c2c
simplify tests significantly
mkcp Nov 5, 2025
1bdfcdf
fix test and ensure that value.Values can set, same as map[string]any
mkcp Nov 5, 2025
e659540
simplify tests even more
mkcp Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/values-templating/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ x-mdx: |
Deploy this example to see values and templates in action:

```bash
# Create and deploy the package (features="values=true" flag required until general release of values)
# Optional: Inspect the manifests and chart values-files (features="values=true" flag required until general release of values)
zarf dev inspect manifests --features="values=true"
zarf dev inspect values-files --features="values=true"

# Create and deploy the package
zarf package create . --confirm --features="values=true"
zarf package deploy zarf-package-values-templating-*.tar.zst --confirm --features="values=true"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ zarf dev inspect manifests [ DIRECTORY ] [flags]
-f, --flavor string The flavor of components to include in the resulting package (i.e. have a matching or empty "only.flavor" key)
-h, --help help for manifests
--kube-version string Override the default helm template KubeVersion when performing a package chart template
--set-values stringToString Set specific values via command line (format: key.path=value) (default [])
--values strings Path to values file(s) for templating
```

### Options inherited from parent commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ zarf dev inspect values-files [ DIRECTORY ] [flags]
-f, --flavor string The flavor of components to include in the resulting package (i.e. have a matching or empty "only.flavor" key)
-h, --help help for values-files
--kube-version string Override the default helm template KubeVersion when performing a package chart template
--set-values stringToString Set specific values via command line (format: key.path=value) (default [])
--values strings Path to values file(s) for templating
```

### Options inherited from parent commands
Expand Down
49 changes: 49 additions & 0 deletions src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/zarf-dev/zarf/src/api/v1alpha1"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/config/lang"
"github.com/zarf-dev/zarf/src/internal/value"
"github.com/zarf-dev/zarf/src/pkg/archive"
"github.com/zarf-dev/zarf/src/pkg/lint"
"github.com/zarf-dev/zarf/src/pkg/logger"
Expand Down Expand Up @@ -124,6 +125,8 @@ type devInspectManifestsOptions struct {
flavor string
createSetVariables map[string]string
deploySetVariables map[string]string
valuesFiles []string
setValues map[string]string
kubeVersion string
outputWriter io.Writer
}
Expand All @@ -149,6 +152,8 @@ func newDevInspectManifestsCommand(v *viper.Viper) *cobra.Command {
cmd.Flags().StringVarP(&o.flavor, "flavor", "f", "", lang.CmdPackageCreateFlagFlavor)
cmd.Flags().StringToStringVar(&o.createSetVariables, "create-set", v.GetStringMapString(VPkgCreateSet), lang.CmdPackageCreateFlagSet)
cmd.Flags().StringToStringVar(&o.deploySetVariables, "deploy-set", v.GetStringMapString(VPkgDeploySet), lang.CmdPackageDeployFlagSet)
cmd.Flags().StringSliceVar(&o.valuesFiles, "values", []string{}, "Path to values file(s) for templating")
cmd.Flags().StringToStringVar(&o.setValues, "set-values", map[string]string{}, "Set specific values via command line (format: key.path=value)")
cmd.Flags().StringVar(&o.kubeVersion, "kube-version", "", lang.CmdDevFlagKubeVersion)

return cmd
Expand All @@ -164,9 +169,29 @@ func (o *devInspectManifestsOptions) run(ctx context.Context, args []string) err
if err != nil {
return err
}

// Parse values from files
values, err := value.ParseFiles(ctx, o.valuesFiles, value.ParseFilesOptions{})
if err != nil {
return fmt.Errorf("unable to parse values files: %w", err)
}

// Apply CLI --set-values overrides
for key, val := range o.setValues {
// Convert key to path format (ensure it starts with .)
path := value.Path(key)
if !strings.HasPrefix(key, ".") {
path = value.Path("." + key)
}
if err := values.Set(path, val); err != nil {
return fmt.Errorf("unable to set value at path %s: %w", key, err)
}
}

opts := packager.InspectDefinitionResourcesOptions{
CreateSetVariables: o.createSetVariables,
DeploySetVariables: o.deploySetVariables,
Values: values,
Flavor: o.flavor,
KubeVersion: o.kubeVersion,
CachePath: cachePath,
Expand Down Expand Up @@ -201,6 +226,8 @@ type devInspectValuesFilesOptions struct {
flavor string
createSetVariables map[string]string
deploySetVariables map[string]string
valuesFiles []string
setValues map[string]string
kubeVersion string
outputWriter io.Writer
}
Expand All @@ -227,6 +254,8 @@ func newDevInspectValuesFilesCommand(v *viper.Viper) *cobra.Command {
cmd.Flags().StringVarP(&o.flavor, "flavor", "f", "", lang.CmdPackageCreateFlagFlavor)
cmd.Flags().StringToStringVar(&o.createSetVariables, "create-set", v.GetStringMapString(VPkgCreateSet), lang.CmdPackageCreateFlagSet)
cmd.Flags().StringToStringVar(&o.deploySetVariables, "deploy-set", v.GetStringMapString(VPkgDeploySet), lang.CmdPackageDeployFlagSet)
cmd.Flags().StringSliceVar(&o.valuesFiles, "values", []string{}, "Path to values file(s) for templating")
cmd.Flags().StringToStringVar(&o.setValues, "set-values", map[string]string{}, "Set specific values via command line (format: key.path=value)")
cmd.Flags().StringVar(&o.kubeVersion, "kube-version", "", lang.CmdDevFlagKubeVersion)

return cmd
Expand All @@ -242,9 +271,29 @@ func (o *devInspectValuesFilesOptions) run(ctx context.Context, args []string) e
if err != nil {
return err
}

// Parse values from files
values, err := value.ParseFiles(ctx, o.valuesFiles, value.ParseFilesOptions{})
Copy link
Member

@AustinAbro321 AustinAbro321 Oct 23, 2025

Choose a reason for hiding this comment

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

Some duplication in this block, that can be pulled out into a common function. I know there's a few active PRs with blocks like this, so I think a follow up PR afterwards would be reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does how up pretty often. This makes sense to me as two steps in the CLI layer because it's coming from two different sources (rather than wrapping both load valuesfiles and setvalues in the same helper func). The setValue step would definitely benefit from abstracting out the loop and path parsing though. I'll make a followup issue for it

if err != nil {
return fmt.Errorf("unable to parse values files: %w", err)
}

// Apply CLI --set-values overrides
for key, val := range o.setValues {
// Convert key to path format (ensure it starts with .)
path := value.Path(key)
if !strings.HasPrefix(key, ".") {
path = value.Path("." + key)
}
if err := values.Set(path, val); err != nil {
return fmt.Errorf("unable to set value at path %s: %w", key, err)
}
}

opts := packager.InspectDefinitionResourcesOptions{
CreateSetVariables: o.createSetVariables,
DeploySetVariables: o.deploySetVariables,
Values: values,
Flavor: o.flavor,
KubeVersion: o.kubeVersion,
CachePath: cachePath,
Expand Down
60 changes: 60 additions & 0 deletions src/cmd/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/zarf-dev/zarf/src/internal/feature"
"github.com/zarf-dev/zarf/src/pkg/lint"
"github.com/zarf-dev/zarf/src/pkg/utils"
"github.com/zarf-dev/zarf/src/test/testutil"
Expand All @@ -21,13 +22,19 @@ func TestDevInspectManifests(t *testing.T) {
t.Parallel()
lint.ZarfSchema = testutil.LoadSchema(t, "../../zarf.schema.json")

// Enable values feature for tests
err := feature.Set([]feature.Feature{{Name: feature.Values, Enabled: true}})
require.NoError(t, err)

tests := []struct {
name string
definitionDir string
expectedOutput string
packageName string
deploySetVariables map[string]string
createSetVariables map[string]string
valuesFiles []string
setValues map[string]string
kubeVersion string
flavor string
expectedErr string
Expand Down Expand Up @@ -79,6 +86,38 @@ func TestDevInspectManifests(t *testing.T) {
definitionDir: filepath.Join("testdata", "inspect-manifests", "empty"),
expectedErr: "0 manifests found",
},
{
name: "manifest with CLI values only",
packageName: "manifest-with-values",
definitionDir: filepath.Join("testdata", "inspect-manifests", "manifest-with-values"),
expectedOutput: filepath.Join("testdata", "inspect-manifests", "manifest-with-values", "expected.yaml"),
valuesFiles: []string{
filepath.Join("testdata", "inspect-manifests", "manifest-with-values", "user-values.yaml"),
},
setValues: map[string]string{
"replicas": "5",
"imageTag": "latest",
},
},
{
name: "manifest with package default values",
packageName: "manifest-with-package-values",
definitionDir: filepath.Join("testdata", "inspect-manifests", "manifest-with-package-values"),
expectedOutput: filepath.Join("testdata", "inspect-manifests", "manifest-with-package-values", "expected-default.yaml"),
},
{
name: "manifest with package values overridden by CLI",
packageName: "manifest-with-package-values",
definitionDir: filepath.Join("testdata", "inspect-manifests", "manifest-with-package-values"),
expectedOutput: filepath.Join("testdata", "inspect-manifests", "manifest-with-package-values", "expected-override.yaml"),
setValues: map[string]string{
"app.name": "overridden-app",
"app.replicas": "5",
"app.image.repository": "nginx",
"app.image.tag": "latest",
"app.port": "8080",
},
},
}

for _, tc := range tests {
Expand All @@ -92,6 +131,8 @@ func TestDevInspectManifests(t *testing.T) {
kubeVersion: tc.kubeVersion,
deploySetVariables: tc.deploySetVariables,
createSetVariables: tc.createSetVariables,
valuesFiles: tc.valuesFiles,
setValues: tc.setValues,
flavor: tc.flavor,
}
err := opts.run(context.Background(), []string{tc.definitionDir})
Expand Down Expand Up @@ -124,6 +165,8 @@ func TestDevInspectValuesFiles(t *testing.T) {
expectedOutput string
packageName string
setVariables map[string]string
valuesFiles []string
setValues map[string]string
expectedErr string
components string
}{
Expand All @@ -145,6 +188,21 @@ func TestDevInspectValuesFiles(t *testing.T) {
definitionDir: filepath.Join("testdata", "inspect-manifests", "manifest"),
expectedErr: "0 values files found",
},
{
name: "chart with values from file and CLI",
packageName: "chart-with-values",
definitionDir: filepath.Join("testdata", "inspect-values-files", "chart-with-values"),
expectedOutput: filepath.Join("testdata", "inspect-values-files", "chart-with-values", "expected.yaml"),
setVariables: map[string]string{
"REPLICAS": "3",
},
valuesFiles: []string{
filepath.Join("testdata", "inspect-values-files", "chart-with-values", "user-values.yaml"),
},
setValues: map[string]string{
"customField": "fromCLI",
},
},
}

for _, tc := range tests {
Expand All @@ -156,6 +214,8 @@ func TestDevInspectValuesFiles(t *testing.T) {
opts := devInspectValuesFilesOptions{
outputWriter: buf,
deploySetVariables: tc.setVariables,
valuesFiles: tc.valuesFiles,
setValues: tc.setValues,
}
err := opts.run(context.Background(), []string{tc.definitionDir})
if tc.expectedErr != "" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.app.name }}
spec:
replicas: {{ .Values.app.replicas }}
selector:
matchLabels:
app: {{ .Values.app.name }}
template:
metadata:
labels:
app: {{ .Values.app.name }}
spec:
containers:
- name: httpd
image: {{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}
ports:
- containerPort: {{ .Values.app.port }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#type: manifest
#source: /var/folders/2s/03x_k4gj0g30dv1qs_p39z3h0000gn/T/zarf-1945337041/httpd/manifests/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-httpd-app
spec:
replicas: 3
selector:
matchLabels:
app: my-httpd-app
template:
metadata:
labels:
app: my-httpd-app
spec:
containers:
- name: httpd
image: httpd:2.4
ports:
- containerPort: 80
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#type: manifest
#source: /var/folders/2s/03x_k4gj0g30dv1qs_p39z3h0000gn/T/zarf-1945337041/httpd/manifests/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: overridden-app
spec:
replicas: 5
selector:
matchLabels:
app: overridden-app
template:
metadata:
labels:
app: overridden-app
spec:
containers:
- name: httpd
image: nginx:latest
ports:
- containerPort: 8080
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app:
name: my-httpd-app
replicas: 3
image:
repository: httpd
tag: "2.4"
port: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: ZarfPackageConfig
metadata:
name: manifest-with-package-values

values:
files:
- default-values.yaml

components:
- name: httpd
manifests:
- name: httpd-manifest
files:
- deployment.yaml
template: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd:{{ .Values.imageTag }}
ports:
- containerPort: {{ .Values.port }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#type: manifest
#source: /var/folders/2s/03x_k4gj0g30dv1qs_p39z3h0000gn/T/zarf-1945337041/httpd/manifests/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
spec:
replicas: 5
selector:
matchLabels:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd:latest
ports:
- containerPort: 8080
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
replicas: 2
imageTag: 2.4
port: 8080
Loading
Loading