add warning with what to when calling init on an implicitly required plugin
This commit is contained in:
parent
c4535b2552
commit
123517aec1
|
@ -125,9 +125,37 @@ func (c *InitCommand) RunContext(buildCtx context.Context, cla *InitArgs) int {
|
||||||
ret = 1
|
ret = 1
|
||||||
}
|
}
|
||||||
if newInstall != nil {
|
if newInstall != nil {
|
||||||
|
if pluginRequirement.Implicit {
|
||||||
|
msg := fmt.Sprintf("Installed implicitly required plugin %s %s in %q", pluginRequirement.Identifier, newInstall.Version, newInstall.BinaryPath)
|
||||||
|
ui.Say(msg)
|
||||||
|
|
||||||
|
warn := fmt.Sprintf(`
|
||||||
|
Warning, init with implicitly required plugin is always going to install the
|
||||||
|
latest possible plugin, if a latest version is backward incompatible with your
|
||||||
|
config file or your version of Packer, a build will fail. To avoid this, lock
|
||||||
|
the plugin version by pasting the following to your configuration:
|
||||||
|
|
||||||
|
packer {
|
||||||
|
required_plugins {
|
||||||
|
%s = {
|
||||||
|
source = "%s"
|
||||||
|
version = "~> %s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
pluginRequirement.Identifier.Type,
|
||||||
|
pluginRequirement.Identifier,
|
||||||
|
newInstall.Version,
|
||||||
|
)
|
||||||
|
ui.Error(warn)
|
||||||
|
} else {
|
||||||
msg := fmt.Sprintf("Installed plugin %s %s in %q", pluginRequirement.Identifier, newInstall.Version, newInstall.BinaryPath)
|
msg := fmt.Sprintf("Installed plugin %s %s in %q", pluginRequirement.Identifier, newInstall.Version, newInstall.BinaryPath)
|
||||||
ui.Say(msg)
|
ui.Say(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ func (cfg *PackerConfig) PluginRequirements() (plugingetter.Requirements, hcl.Di
|
||||||
Accessor: name,
|
Accessor: name,
|
||||||
Identifier: block.Type,
|
Identifier: block.Type,
|
||||||
VersionConstraints: block.Requirement.Required,
|
VersionConstraints: block.Requirement.Required,
|
||||||
|
Implicit: block.PluginDependencyReason == PluginDependencyImplicit,
|
||||||
})
|
})
|
||||||
uniq[name] = block
|
uniq[name] = block
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ type Requirement struct {
|
||||||
// VersionConstraints as defined by user. Empty ( to be avoided ) means
|
// VersionConstraints as defined by user. Empty ( to be avoided ) means
|
||||||
// highest found version.
|
// highest found version.
|
||||||
VersionConstraints version.Constraints
|
VersionConstraints version.Constraints
|
||||||
|
|
||||||
|
// was this require implicitly guessed ?
|
||||||
|
Implicit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type BinaryInstallationOptions struct {
|
type BinaryInstallationOptions struct {
|
||||||
|
|
Loading…
Reference in New Issue