Skip to content

feat: add --set-values flags and migrate --set to alias new --set-variables#4466

Merged
mkcp merged 19 commits intomainfrom
mkcp/migrate-vars-flags
Jan 22, 2026
Merged

feat: add --set-values flags and migrate --set to alias new --set-variables#4466
mkcp merged 19 commits intomainfrom
mkcp/migrate-vars-flags

Conversation

@mkcp
Copy link
Contributor

@mkcp mkcp commented Dec 10, 2025

Description

This PR adds the --set-values flag so users can directly override values via the CLI, and begins the path to migrating --set. To do so, we add the --set-variables flag (or versions of it like --deploy-set-variables) and change the description of --set to indicate that it now aliases --set-variables. This alias is just a documentation change in the CLI help text: the flags function identically.

Related Issue

Fixes #4224

Checklist before merging

mkcp added 2 commits December 10, 2025 10:09
…e --set description to indicate it's now an alias for this flag

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp self-assigned this Dec 10, 2025
@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for zarf-docs ready!

Name Link
🔨 Latest commit 9262bcc
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6972a2a470351100082441a4
😎 Deploy Preview https://deploy-preview-4466--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.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 63.63636% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cmd/package.go 44.82% 16 Missing ⚠️
src/cmd/dev.go 73.33% 12 Missing ⚠️
Files with missing lines Coverage Δ
src/cmd/initialize.go 27.20% <100.00%> (+0.56%) ⬆️
src/cmd/viper.go 54.44% <ø> (ø)
src/cmd/dev.go 46.25% <73.33%> (+0.96%) ⬆️
src/cmd/package.go 37.64% <44.82%> (-0.10%) ⬇️

... and 3 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 December 10, 2025 12:13
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp moved this to In progress in Zarf Dec 10, 2025
mkcp added 3 commits December 10, 2025 12:28
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp marked this pull request as ready for review December 10, 2025 20:56
@mkcp mkcp requested review from a team as code owners December 10, 2025 20:56
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.

migration makes sense - added some thoughts around guardrails natively available in cobra that we might consider.


// Init package set variable flags
cmd.Flags().StringToStringVar(&o.setVariables, "set", v.GetStringMapString(VPkgDeploySet), lang.CmdInitFlagSet)
cmd.Flags().StringToStringVar(&o.setVariables, "set", v.GetStringMapString(VPkgDeploySet), "Alias for --set-variables")
Copy link
Member

Choose a reason for hiding this comment

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

Should we explicitly mark these as deprecated?

cmd.Flags().MarkDeprecated("set", "use --set-variables instead")

Copy link
Member

Choose a reason for hiding this comment

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

Rather than having a separate command as an alias that we mark as deprecated or hide, I think it would be better to use the builtin cobra functionality for aliasing a command. This leads to a more intuitive experience around viper config, and will lead to an easier time aliasing --set-values to --set in the future in the event that variables is fully replaced

For instance
cmd.Flags().StringToStringVarP(&o.setVariables, "set-variables", "set", v.GetStringMapString(VPkgCreateSet), lang.CmdPackageCreateFlagSetVariables)

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 understand the argument for making --set a flag shorthand, but I don't think I agree with doing so. Typically the shorthand for flags are one letter and intended to be stable for the life of the flag. Implementing --set as a separate command allows us to notify users when the behavior is deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay I was recommending this with the intent that --set would one day be the alias to --set-values once --set-variables is removed. Given that we plan on removing --set at some point, I would agree with @brandtkeller's assessment that it should be deprecated

Copy link
Member

Choose a reason for hiding this comment

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

I see set marked as deprecated in the package commands but not here in init so I figured id follow up here - do we intend to set this to deprecated as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes this has an alternative flag so it's meant to be deprecated. Updating


// Init package set variable flags
cmd.Flags().StringToStringVar(&o.setVariables, "set", v.GetStringMapString(VPkgDeploySet), lang.CmdInitFlagSet)
cmd.Flags().StringToStringVar(&o.setVariables, "set", v.GetStringMapString(VPkgDeploySet), "Alias for --set-variables")
Copy link
Member

Choose a reason for hiding this comment

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

Rather than having a separate command as an alias that we mark as deprecated or hide, I think it would be better to use the builtin cobra functionality for aliasing a command. This leads to a more intuitive experience around viper config, and will lead to an easier time aliasing --set-values to --set in the future in the event that variables is fully replaced

For instance
cmd.Flags().StringToStringVarP(&o.setVariables, "set-variables", "set", v.GetStringMapString(VPkgCreateSet), lang.CmdPackageCreateFlagSetVariables)

src/cmd/dev.go Outdated
cmd.Flags().StringToStringVar(&o.createSetVariables, "create-set", v.GetStringMapString(VPkgCreateSet), lang.CmdDevFlagSet)
cmd.Flags().StringToStringVar(&o.deploySetVariables, "deploy-set", v.GetStringMapString(VPkgDeploySet), lang.CmdPackageDeployFlagSet)
cmd.Flags().StringToStringVar(&o.createSetVariables, "create-set", v.GetStringMapString(VPkgCreateSet), "Alias for --create-set-variables")
cmd.Flags().StringToStringVar(&o.createSetVariables, "create-set-variables", v.GetStringMapString(VPkgCreateSet), lang.CmdDevFlagSetVariables)
Copy link
Member

Choose a reason for hiding this comment

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

IMO we shouldn't add the variables verbiage to create time templates. Generally I think we should refer to these as package templates. I just noticed that Zarf is inconsistent right now since we call them package variables in this flag, and package templates in our docs. Still, I don't think we'll ever have two types of package templates, at least not in the same API version, so I'm not sure extra verbosity is helpful.

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 get what you mean now. I updated the cli string verbiage and config structs to package templates / PkgTmpl, but only in the cmd pkg to keep the scope of the PR constrained. This should mean that users will now see "package templates" in the CLI layer, but internally there are still references to CreateSetVariables in dev. This should give us a step towards more consistent handling without trying to solve all of it here.

mkcp added 2 commits January 14, 2026 13:40
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@michalszynkiewicz
Copy link
Contributor

Do I understand correctly that we only support overriding values at deployment time and not the packaging time? Or is there a way to override when packaging too?

mkcp added 3 commits January 15, 2026 10:51
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp
Copy link
Contributor Author

mkcp commented Jan 22, 2026

@michalszynkiewicz Following up here and from other threads - the values files included in the package definition are intended to be the package defaults, and the set of values the package is created with. Allowing those defaults to be overrided at create-time in a way changes the declarative nature of the package and means you're building a different package than the definition, in a way.

After discussion, we'd be more likely to meet this usecase with more powerful package templates resolved in a pre-processing step. Then you'd be able to programmatically generate different packages from a base package definition e.g zarf.yaml.tmpl, and then run zarf package create on the result once all templates are resolved.

mkcp added 4 commits January 22, 2026 10:30
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@mkcp mkcp changed the title Add --set-values flags and migrate --set to alias new --set-variables feat: add --set-values flags and migrate --set to alias new --set-variables Jan 22, 2026
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@AustinAbro321 AustinAbro321 dismissed their stale review January 22, 2026 22:03

Dismissing my review here to not block potential merge before next release

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
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.

lgtm

@mkcp mkcp added this pull request to the merge queue Jan 22, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 22, 2026
…iables (#4466)

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2026
@mkcp mkcp added this pull request to the merge queue Jan 22, 2026
Merged via the queue into main with commit 345765d Jan 22, 2026
42 checks passed
@mkcp mkcp deleted the mkcp/migrate-vars-flags branch January 22, 2026 23:45
@github-project-automation github-project-automation bot moved this from In progress to Done in Zarf Jan 22, 2026
chaospuppy pushed a commit to chaospuppy/zarf that referenced this pull request Jan 23, 2026
…iables (zarf-dev#4466)

Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add --set-value flag for granular values key overrides

4 participants