feat: add --set-values flags and migrate --set to alias new --set-variables#4466
feat: add --set-values flags and migrate --set to alias new --set-variables#4466
Conversation
…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>
✅ Deploy Preview for zarf-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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>
brandtkeller
left a comment
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Should we explicitly mark these as deprecated?
cmd.Flags().MarkDeprecated("set", "use --set-variables instead")There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
|
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? |
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
|
@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 |
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>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
Dismissing my review here to not block potential merge before next release
Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…iables (#4466) Signed-off-by: Kit Patella <kit@defenseunicorns.com>
…iables (zarf-dev#4466) Signed-off-by: Kit Patella <kit@defenseunicorns.com> Signed-off-by: Tim Seagren <timseagren@defenseunicorns.com>
Description
This PR adds the
--set-valuesflag so users can directly override values via the CLI, and begins the path to migrating--set. To do so, we add the--set-variablesflag (or versions of it like--deploy-set-variables) and change the description of--setto 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