Add constants for legacy mode values

wilken/packer-legacy-mode
Wilken Rivera 4 years ago
parent ed441c1806
commit bc697e0ce7

@ -113,7 +113,7 @@ func (m *Meta) GetConfig(cla *MetaArgs) (packer.Handler, int) {
// This is an internal-only method that should be called by commands that don't have
// a different mode when handling legacy JSON templates; mainly build, validate.
func DisplayLegacyConfigWarning(ui packersdk.Ui) {
if v := os.Getenv("PACKER_LEGACY_MODE"); strings.ToLower(v) == "on" {
if v := os.Getenv(PackerLegacyModeEnv); strings.ToUpper(v) == packerLegacyModeOn {
return
}
@ -130,11 +130,11 @@ templates will continue to work but users are encouraged to move to HCL style te
See: https://learn.hashicorp.com/tutorials/packer/hcl2-upgrade
`)
coloredUi.Say(`In JSON mode automatic loading of vendored plugins is enabled by default. In future
this feature will be removed and Packer will rely only on system installed plugins.
To disable automatic loading of vendored plugins set PACKER_LEGACY_MODE=off
coloredUi.Say(fmt.Sprintf(`In JSON mode automatic loading of vendored plugins is enabled by default. In the
future this feature will be removed and Packer will rely only on system installed plugins.
To disable automatic loading of vendored plugins set %s=%s
See: https://packer.io/docs/templates/legacy-mode
`)
`, PackerLegacyModeEnv, packerLegacyModeOff))
}

@ -23,6 +23,19 @@ const (
FlagSetVars
)
const (
/*
PACKER_LEGACY_MODE is an environment variable used by Packer to control features consider legacy as of 1.8.0.
By default when the variable is unset Packer will display warnings to the user.
Setting PACKER_LEGACY_MODE=OFF will display warnings to the user when running, and may disable other features.
Setting PACKER_LEGACY_MODE=ON will not display warnings, and will Packer with all legacy features enabled.
*/
PackerLegacyModeEnv string = "PACKER_LEGACY_MODE"
packerLegacyModeOn string = "ON"
packerLegacyModeOff string = "OFF"
)
// Meta contains the meta-options and functionality that nearly every
// Packer command inherits.
type Meta struct {

@ -191,10 +191,10 @@ var VendoredPostProcessors = map[string]packersdk.PostProcessor{
// set of plugins.
func init() {
// By default PACKER_LEGACY_MODE=auto to enable automatic loading of vendored plugins.
// By default PACKER_LEGACY_MODE is unset to enable automatic loading of vendored plugins.
// In preparation for removing vendored plugins entirely we are providing users a flag to
// to control if vendored plugins should be loaded or not.
if v := os.Getenv("PACKER_LEGACY_MODE"); strings.ToLower(v) == "off" {
if v := os.Getenv(PackerLegacyModeEnv); strings.ToUpper(v) == packerLegacyModeOff {
return
}

Loading…
Cancel
Save