mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-13 10:40:05 -04:00
command: add --release-only flag to validate/build
Since we added the capability for the plugin discovery to ignore installed pre-releases of plugins, we give that capacity to the validate and build commands, through a new command-line flag: release-only.
This commit is contained in:
parent
9f7e6ca52b
commit
b5848b9913
3 changed files with 16 additions and 0 deletions
|
|
@ -86,6 +86,11 @@ func writeDiags(ui packersdk.Ui, files map[string]*hcl.File, diags hcl.Diagnosti
|
|||
}
|
||||
|
||||
func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int {
|
||||
// Set the release only flag if specified as argument
|
||||
//
|
||||
// This deactivates the capacity for Packer to load development binaries.
|
||||
c.CoreConfig.Components.PluginConfig.ReleasesOnly = cla.ReleaseOnly
|
||||
|
||||
packerStarter, ret := c.GetConfig(&cla.MetaArgs)
|
||||
if ret != 0 {
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ func (ba *BuildArgs) AddFlagSets(flags *flag.FlagSet) {
|
|||
flags.Var(flagOnError, "on-error", "")
|
||||
|
||||
flags.BoolVar(&ba.MetaArgs.WarnOnUndeclaredVar, "warn-on-undeclared-var", false, "Show warnings for variable files containing undeclared variables.")
|
||||
|
||||
flags.BoolVar(&ba.ReleaseOnly, "ignore-prerelease-plugins", false, "Disable the loading of prerelease plugin binaries (x.y.z-<prerelease-name>.")
|
||||
|
||||
ba.MetaArgs.AddFlagSets(flags)
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +103,7 @@ type BuildArgs struct {
|
|||
Color, TimestampUi, MachineReadable bool
|
||||
ParallelBuilds int64
|
||||
OnError string
|
||||
ReleaseOnly bool
|
||||
}
|
||||
|
||||
func (ia *InitArgs) AddFlagSets(flags *flag.FlagSet) {
|
||||
|
|
@ -142,6 +146,7 @@ func (va *ValidateArgs) AddFlagSets(flags *flag.FlagSet) {
|
|||
flags.BoolVar(&va.SyntaxOnly, "syntax-only", false, "check syntax only")
|
||||
flags.BoolVar(&va.NoWarnUndeclaredVar, "no-warn-undeclared-var", false, "Ignore warnings for variable files containing undeclared variables.")
|
||||
flags.BoolVar(&va.EvaluateDatasources, "evaluate-datasources", false, "evaluate datasources for validation (HCL2 only, may incur costs)")
|
||||
flags.BoolVar(&va.ReleaseOnly, "ignore-prerelease-plugins", false, "Disable the loading of prerelease plugin binaries (x.y.z-<prerelease-name>.")
|
||||
|
||||
va.MetaArgs.AddFlagSets(flags)
|
||||
}
|
||||
|
|
@ -151,6 +156,7 @@ type ValidateArgs struct {
|
|||
MetaArgs
|
||||
SyntaxOnly, NoWarnUndeclaredVar bool
|
||||
EvaluateDatasources bool
|
||||
ReleaseOnly bool
|
||||
}
|
||||
|
||||
func (va *InspectArgs) AddFlagSets(flags *flag.FlagSet) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ func (c *ValidateCommand) ParseArgs(args []string) (*ValidateArgs, int) {
|
|||
}
|
||||
|
||||
func (c *ValidateCommand) RunContext(ctx context.Context, cla *ValidateArgs) int {
|
||||
// Set the release only flag if specified as argument
|
||||
//
|
||||
// This deactivates the capacity for Packer to load development binaries.
|
||||
c.CoreConfig.Components.PluginConfig.ReleasesOnly = cla.ReleaseOnly
|
||||
|
||||
// By default we want to inform users of undeclared variables when validating but not during build time.
|
||||
cla.MetaArgs.WarnOnUndeclaredVar = true
|
||||
if cla.NoWarnUndeclaredVar {
|
||||
|
|
|
|||
Loading…
Reference in a new issue