diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index e7cfd5814..95091ad98 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -46,6 +46,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 5aad1e633..9fb431583 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -194,6 +194,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 7d99facf1..4d4934c43 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -85,6 +85,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index d938cdd46..ca7125980 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -84,6 +84,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index 3ff801907..d3fb1a03f 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -100,6 +100,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { SourceAMI: `{{ .SourceAMI }} `, } err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, }, raws...) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 7e3256d22..7c050b88e 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -107,6 +107,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 4617ebe2f..e0e0eacc4 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -153,6 +153,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs["vm"] = CreateVMMetadataTemplateFunc() md := &mapstructure.Metadata{} err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderID, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 25284b0b2..8fa9d9844 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -89,6 +89,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: hypervcommon.BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index b99317695..622917ac4 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -82,6 +82,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: hypervcommon.BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index 9e9013ca8..9fb801018 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -17,6 +17,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BUILDER_ID, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/null/config.go b/builder/null/config.go index aa39b1163..6c7fcb9c2 100644 --- a/builder/null/config.go +++ b/builder/null/config.go @@ -21,6 +21,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateFilter: &interpolate.RenderFilter{}, }, raws...) diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 432e0810f..44df3ff9e 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -40,6 +40,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, }, raws...) diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 7c2cca0a3..83de3d0c0 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -45,6 +45,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = osccommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index 711cfeba4..b38ea3d8d 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -46,6 +46,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = osccommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 269565008..48fd55e26 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -53,6 +53,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { SourceOMI: `{{ .SourceOMI }} `, } err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, }, raws...) diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 3d6d0e391..389fd60d3 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -66,6 +66,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { b.config.ctx.Funcs = osccommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index e3da391ab..92ca28f42 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -87,6 +87,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index eb60975ac..30cc4c42d 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -35,6 +35,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/triton/builder.go b/builder/triton/builder.go index 6ee06785c..70e8cd88d 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -27,6 +27,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { errs := &multierror.Error{} err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, }, raws...) diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 9d5c8c0f1..ecabecb48 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -38,6 +38,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 045aa47c7..f1bbefc99 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -154,6 +154,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 867589036..207473f7a 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -117,6 +117,7 @@ func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstruct func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { err := config.Decode(&b.config, &config.DecodeOpts{ + PluginType: vboxcommon.BuilderId, // "mitchellh.virtualbox" Interpolate: true, InterpolateContext: &b.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index 40e47ad56..ac8be5e7b 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -82,6 +82,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: vboxcommon.BuilderId, // "mitchellh.virtualbox" Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/virtualbox/vm/config.go b/builder/virtualbox/vm/config.go index 973be08ed..6f4b6b823 100644 --- a/builder/virtualbox/vm/config.go +++ b/builder/virtualbox/vm/config.go @@ -66,6 +66,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: vboxcommon.BuilderId, // "mitchellh.virtualbox" Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/vsphere/clone/config.go b/builder/vsphere/clone/config.go index c2d9c2e8a..c841b5a56 100644 --- a/builder/vsphere/clone/config.go +++ b/builder/vsphere/clone/config.go @@ -52,6 +52,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: common.BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/vsphere/iso/config.go b/builder/vsphere/iso/config.go index 2d83c35d0..3d9601524 100644 --- a/builder/vsphere/iso/config.go +++ b/builder/vsphere/iso/config.go @@ -53,6 +53,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: common.BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/cmd/generate-fixer-deprecations/main.go b/cmd/generate-fixer-deprecations/main.go index 13b576d93..8c355c9ad 100644 --- a/cmd/generate-fixer-deprecations/main.go +++ b/cmd/generate-fixer-deprecations/main.go @@ -1,8 +1,10 @@ package main import ( + "bytes" "flag" "fmt" + "go/format" "os" "path/filepath" "strings" @@ -11,20 +13,19 @@ import ( "github.com/hashicorp/packer/fix" ) -var deprecatedOptsTemplate = template.Must(template.New("deprecatedOptsTemplate"). - Parse(`// +var deprecatedOptsTemplate = template.Must(template.New("deprecatedOptsTemplate").Funcs(template.FuncMap{"StringsJoin": strings.Join}).Parse(`// package config -var DeprecatedOptions = []string{ -{{- range .DeprecatedOpts}} - "{{.}}", +var DeprecatedOptions = map[string][]string{ +{{- range $key, $value := .DeprecatedOpts}} + "{{$key}}": []string{"{{ StringsJoin . "\", \"" }}"}, {{- end}} } `)) type executeOpts struct { - DeprecatedOpts []string + DeprecatedOpts map[string][]string } func main() { @@ -45,7 +46,7 @@ func main() { packerDir := paths[0] // Load all deprecated options from all active fixers - allDeprecatedOpts := []string{} + allDeprecatedOpts := map[string][]string{} for _, name := range fix.FixerOrder { fixer, ok := fix.Fixers[name] if !ok { @@ -53,20 +54,35 @@ func main() { } deprecated := fixer.DeprecatedOptions() - allDeprecatedOpts = append(allDeprecatedOpts, deprecated...) + for k, v := range deprecated { + if allDeprecatedOpts[k] == nil { + allDeprecatedOpts[k] = v + } else { + allDeprecatedOpts[k] = append(allDeprecatedOpts[k], v...) + } + } } deprecated_path := filepath.Join(packerDir, "helper", "config", "deprecated_options.go") + buf := bytes.Buffer{} + + // execute template into buffer + deprecated := &executeOpts{DeprecatedOpts: allDeprecatedOpts} + err = deprecatedOptsTemplate.Execute(&buf, deprecated) + // we've written unformatted go code to the file. now we have to format it. + out, err := format.Source(buf.Bytes()) + if err != nil { + panic(err) + } + outputFile, err := os.Create(deprecated_path) if err != nil { panic(err) } + _, err = outputFile.Write(out) defer outputFile.Close() - - deprecated := &executeOpts{DeprecatedOpts: allDeprecatedOpts} - err = deprecatedOptsTemplate.Execute(outputFile, deprecated) if err != nil { fmt.Printf("%v", err) os.Exit(1) diff --git a/fix/fixer.go b/fix/fixer.go index 7f0beef10..cf50d0c30 100644 --- a/fix/fixer.go +++ b/fix/fixer.go @@ -6,7 +6,7 @@ type Fixer interface { // this fixer. It is used to generate a list of deprecated options that the // template parser checks against to warn users that they need to call // `packer fix` against their templates after upgrading. - DeprecatedOptions() []string + DeprecatedOptions() map[string][]string // Fix takes a raw map structure input, potentially transforms it // in some way, and returns the new, transformed structure. The diff --git a/fix/fixer_amazon_enhanced_networking.go b/fix/fixer_amazon_enhanced_networking.go index ce502ee37..dd7133171 100644 --- a/fix/fixer_amazon_enhanced_networking.go +++ b/fix/fixer_amazon_enhanced_networking.go @@ -10,8 +10,10 @@ import ( // with the clearer "ena_support". This disambiguates ena_support from sriov_support. type FixerAmazonEnhancedNetworking struct{} -func (FixerAmazonEnhancedNetworking) DeprecatedOptions() []string { - return []string{"enhanced_networking"} +func (FixerAmazonEnhancedNetworking) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"enhanced_networking"}, + } } func (FixerAmazonEnhancedNetworking) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_amazon_private_ip.go b/fix/fixer_amazon_private_ip.go index 7924f99e1..7a6c483ff 100644 --- a/fix/fixer_amazon_private_ip.go +++ b/fix/fixer_amazon_private_ip.go @@ -12,8 +12,10 @@ import ( // true` with `"ssh_interface": "private_ip"` type FixerAmazonPrivateIP struct{} -func (FixerAmazonPrivateIP) DeprecatedOptions() []string { - return []string{"ssh_private_ip"} +func (FixerAmazonPrivateIP) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"ssh_private_ip"}, + } } func (FixerAmazonPrivateIP) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_amazon_shutdown_behavior.go b/fix/fixer_amazon_shutdown_behavior.go index 04c52ab04..b73c67e1f 100644 --- a/fix/fixer_amazon_shutdown_behavior.go +++ b/fix/fixer_amazon_shutdown_behavior.go @@ -10,8 +10,10 @@ import ( // template in a Amazon builder type FixerAmazonShutdownBehavior struct{} -func (FixerAmazonShutdownBehavior) DeprecatedOptions() []string { - return []string{"shutdown_behaviour"} +func (FixerAmazonShutdownBehavior) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"shutdown_behaviour"}, + } } func (FixerAmazonShutdownBehavior) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_amazon_spot_price_product.go b/fix/fixer_amazon_spot_price_product.go index c1bd537b9..ad0f64815 100644 --- a/fix/fixer_amazon_spot_price_product.go +++ b/fix/fixer_amazon_spot_price_product.go @@ -8,8 +8,10 @@ import ( // from Amazon builder templates type FixerAmazonSpotPriceProductDeprecation struct{} -func (FixerAmazonSpotPriceProductDeprecation) DeprecatedOptions() []string { - return []string{"spot_price_auto_product"} +func (FixerAmazonSpotPriceProductDeprecation) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"spot_price_auto_product"}, + } } func (FixerAmazonSpotPriceProductDeprecation) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_amazon_temporary_security_group_cidrs.go b/fix/fixer_amazon_temporary_security_group_cidrs.go index adc8055fb..eccfe855e 100644 --- a/fix/fixer_amazon_temporary_security_group_cidrs.go +++ b/fix/fixer_amazon_temporary_security_group_cidrs.go @@ -8,8 +8,10 @@ import ( type FixerAmazonTemporarySecurityCIDRs struct{} -func (FixerAmazonTemporarySecurityCIDRs) DeprecatedOptions() []string { - return []string{"temporary_security_group_source_cidr"} +func (FixerAmazonTemporarySecurityCIDRs) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"temporary_security_group_source_cidr"}, + } } func (FixerAmazonTemporarySecurityCIDRs) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_azure_exclude_from_latest.go b/fix/fixer_azure_exclude_from_latest.go index d46049c1b..dad0ed690 100644 --- a/fix/fixer_azure_exclude_from_latest.go +++ b/fix/fixer_azure_exclude_from_latest.go @@ -10,8 +10,10 @@ import ( // template in an Azure builder type FixerAzureExcludeFromLatest struct{} -func (FixerAzureExcludeFromLatest) DeprecatedOptions() []string { - return []string{"exlude_from_latest"} +func (FixerAzureExcludeFromLatest) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "Azure*": []string{"exlude_from_latest"}, + } } func (FixerAzureExcludeFromLatest) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_clean_image_name.go b/fix/fixer_clean_image_name.go index f2880ff8c..5ba1a3a3c 100644 --- a/fix/fixer_clean_image_name.go +++ b/fix/fixer_clean_image_name.go @@ -11,8 +11,12 @@ import ( // calls with "clean_resource_name" type FixerCleanImageName struct{} -func (FixerCleanImageName) DeprecatedOptions() []string { - return []string{"clean_image_name", "clean_ami_name"} +func (FixerCleanImageName) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*amazon*": []string{"clean_ami_name"}, + "packer.googlecompute": []string{"clean_image_name"}, + "Azure*": []string{"clean_image_name"}, + } } func (FixerCleanImageName) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_comm_config.go b/fix/fixer_comm_config.go index 54c658970..09781a04a 100644 --- a/fix/fixer_comm_config.go +++ b/fix/fixer_comm_config.go @@ -10,9 +10,11 @@ import ( // for variables host_port_min, host_port_max, skip_nat_mapping type FixerCommConfig struct{} -func (FixerCommConfig) DeprecatedOptions() []string { - return []string{"ssh_host_port_min", "ssh_host_port_max", - "ssh_skip_nat_mapping"} +func (FixerCommConfig) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"ssh_host_port_min", "ssh_host_port_max", + "ssh_skip_nat_mapping"}, + } } func (FixerCommConfig) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_createtime.go b/fix/fixer_createtime.go index d4045a17a..eda513ffc 100644 --- a/fix/fixer_createtime.go +++ b/fix/fixer_createtime.go @@ -10,8 +10,8 @@ import ( // calls with "{{timestamp}" type FixerCreateTime struct{} -func (FixerCreateTime) DeprecatedOptions() []string { - return []string{} +func (FixerCreateTime) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerCreateTime) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_docker_email.go b/fix/fixer_docker_email.go index f7984a871..17a1a1300 100644 --- a/fix/fixer_docker_email.go +++ b/fix/fixer_docker_email.go @@ -4,8 +4,12 @@ import "github.com/mitchellh/mapstructure" type FixerDockerEmail struct{} -func (FixerDockerEmail) DeprecatedOptions() []string { - return []string{"login_email"} +func (FixerDockerEmail) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "packer.docker": []string{"login_email"}, + "packer.post-processor.docker-import": []string{"login_email"}, + } + } func (FixerDockerEmail) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_galaxy_command.go b/fix/fixer_galaxy_command.go index 8b455cf93..c819dc69e 100644 --- a/fix/fixer_galaxy_command.go +++ b/fix/fixer_galaxy_command.go @@ -8,8 +8,10 @@ import ( // environment variables and replace galaxycommand with galaxy_command type FixerGalaxyCommand struct{} -func (FixerGalaxyCommand) DeprecatedOptions() []string { - return []string{"galaxycommand"} +func (FixerGalaxyCommand) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "ansible": []string{"galaxycommand"}, + } } func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_hyperv_cpu_and_ram_naming.go b/fix/fixer_hyperv_cpu_and_ram_naming.go index 71567d298..c4516c020 100644 --- a/fix/fixer_hyperv_cpu_and_ram_naming.go +++ b/fix/fixer_hyperv_cpu_and_ram_naming.go @@ -4,12 +4,13 @@ import ( "github.com/mitchellh/mapstructure" ) -// FizerHypervCPUandRAM fixes the typo in "clone_from_vmxc_path" replacing -// it with "clone_from_vmcx_path" in Hyper-V VMCX builder templates +// FizerHypervCPUandRAM changes `cpu` to `cpus` and `ram_size` to `memory` type FizerHypervCPUandRAM struct{} -func (FizerHypervCPUandRAM) DeprecatedOptions() []string { - return []string{"cpu", "ram_size"} +func (FizerHypervCPUandRAM) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "MSOpenTech.hyperv": []string{"cpu", "ram_size"}, + } } func (FizerHypervCPUandRAM) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_hyperv_deprecations.go b/fix/fixer_hyperv_deprecations.go index 09ad1e1de..3b9582ff5 100644 --- a/fix/fixer_hyperv_deprecations.go +++ b/fix/fixer_hyperv_deprecations.go @@ -8,8 +8,10 @@ import ( // from Hyper-V ISO builder templates type FixerHypervDeprecations struct{} -func (FixerHypervDeprecations) DeprecatedOptions() []string { - return []string{"vhd_temp_path"} +func (FixerHypervDeprecations) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "MSOpenTech.hyperv": []string{"vhd_temp_path"}, + } } func (FixerHypervDeprecations) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_hyperv_vmxc_typo.go b/fix/fixer_hyperv_vmxc_typo.go index 939afca11..2063fae40 100644 --- a/fix/fixer_hyperv_vmxc_typo.go +++ b/fix/fixer_hyperv_vmxc_typo.go @@ -8,8 +8,10 @@ import ( // it with "clone_from_vmcx_path" in Hyper-V VMCX builder templates type FixerHypervVmxcTypo struct{} -func (FixerHypervVmxcTypo) DeprecatedOptions() []string { - return []string{"clone_from_vmxc_path"} +func (FixerHypervVmxcTypo) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "MSOpenTech.hyperv": []string{"clone_from_vmxc_path"}, + } } func (FixerHypervVmxcTypo) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_iso_checksum_type_and_url.go b/fix/fixer_iso_checksum_type_and_url.go index 82bdf4e0e..07aaf6621 100644 --- a/fix/fixer_iso_checksum_type_and_url.go +++ b/fix/fixer_iso_checksum_type_and_url.go @@ -8,8 +8,10 @@ import ( // "iso_checksum_type" to put everything in the checksum field. type FixerISOChecksumTypeAndURL struct{} -func (FixerISOChecksumTypeAndURL) DeprecatedOptions() []string { - return []string{"iso_checksum_url", "iso_checksum_type"} +func (FixerISOChecksumTypeAndURL) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"iso_checksum_url", "iso_checksum_type"}, + } } func (FixerISOChecksumTypeAndURL) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_iso_md5.go b/fix/fixer_iso_md5.go index 9a5d6e834..6aa69a7c7 100644 --- a/fix/fixer_iso_md5.go +++ b/fix/fixer_iso_md5.go @@ -8,8 +8,10 @@ import ( // with the newer "iso_checksum" and "iso_checksum_type" within builders. type FixerISOMD5 struct{} -func (FixerISOMD5) DeprecatedOptions() []string { - return []string{"iso_md5"} +func (FixerISOMD5) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"iso_md5"}, + } } func (FixerISOMD5) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_parallels_deprecations.go b/fix/fixer_parallels_deprecations.go index 0323f8140..cf8dd001b 100644 --- a/fix/fixer_parallels_deprecations.go +++ b/fix/fixer_parallels_deprecations.go @@ -9,8 +9,10 @@ import ( // "guest_os_type", possibly overwriting any existing "guest_os_type" type FixerParallelsDeprecations struct{} -func (FixerParallelsDeprecations) DeprecatedOptions() []string { - return []string{"parallels_tools_host_path", "guest_os_distribution"} +func (FixerParallelsDeprecations) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "packer.parallels": []string{"parallels_tools_host_path", "guest_os_distribution"}, + } } func (FixerParallelsDeprecations) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_parallels_headless.go b/fix/fixer_parallels_headless.go index 3611b6a2d..d1e0d2fc6 100644 --- a/fix/fixer_parallels_headless.go +++ b/fix/fixer_parallels_headless.go @@ -7,8 +7,10 @@ import ( // FixerParallelsHeadless removes "headless" from a template in a Parallels builder type FixerParallelsHeadless struct{} -func (FixerParallelsHeadless) DeprecatedOptions() []string { - return []string{"headless"} +func (FixerParallelsHeadless) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "packer.parallels": []string{"headless"}, + } } func (FixerParallelsHeadless) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_powershell_escapes.go b/fix/fixer_powershell_escapes.go index bbc496b4b..4fa06ff6d 100644 --- a/fix/fixer_powershell_escapes.go +++ b/fix/fixer_powershell_escapes.go @@ -10,8 +10,8 @@ import ( // environment variables and elevated username and password strings type FixerPowerShellEscapes struct{} -func (FixerPowerShellEscapes) DeprecatedOptions() []string { - return []string{} +func (FixerPowerShellEscapes) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerPowerShellEscapes) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_pp_docker_tag_tags.go b/fix/fixer_pp_docker_tag_tags.go index 6a7beb45f..1673ec7b7 100644 --- a/fix/fixer_pp_docker_tag_tags.go +++ b/fix/fixer_pp_docker_tag_tags.go @@ -9,8 +9,10 @@ import ( // FixerDockerTagtoTags renames tag to tags type FixerDockerTagtoTags struct{} -func (FixerDockerTagtoTags) DeprecatedOptions() []string { - return []string{"tag"} +func (FixerDockerTagtoTags) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "packer.post-processor.docker-tag": []string{"tag"}, + } } func (FixerDockerTagtoTags) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_pp_manifest_filename.go b/fix/fixer_pp_manifest_filename.go index 25d131e59..d6ad6a9a4 100644 --- a/fix/fixer_pp_manifest_filename.go +++ b/fix/fixer_pp_manifest_filename.go @@ -7,8 +7,10 @@ import ( // FixerManifestFilename renames any Filename to Output type FixerManifestFilename struct{} -func (FixerManifestFilename) DeprecatedOptions() []string { - return []string{"filename"} +func (FixerManifestFilename) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "packer.post-processor.manifest": []string{"filename"}, + } } func (FixerManifestFilename) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_pp_vagrant_override.go b/fix/fixer_pp_vagrant_override.go index ebb80a5f3..fec17f4ba 100644 --- a/fix/fixer_pp_vagrant_override.go +++ b/fix/fixer_pp_vagrant_override.go @@ -7,8 +7,8 @@ import "github.com/mitchellh/mapstructure" // as part of Packer 0.5.0. type FixerVagrantPPOverride struct{} -func (FixerVagrantPPOverride) DeprecatedOptions() []string { - return []string{} +func (FixerVagrantPPOverride) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerVagrantPPOverride) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_qemu_disk_size.go b/fix/fixer_qemu_disk_size.go index 706276d36..ef6b8459f 100644 --- a/fix/fixer_qemu_disk_size.go +++ b/fix/fixer_qemu_disk_size.go @@ -9,8 +9,8 @@ import ( // FixerQEMUDiskSize updates disk_size from a string to int for QEMU builders type FixerQEMUDiskSize struct{} -func (FixerQEMUDiskSize) DeprecatedOptions() []string { - return []string{} +func (FixerQEMUDiskSize) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerQEMUDiskSize) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_qemu_host_port.go b/fix/fixer_qemu_host_port.go index c1f6a3e3a..a1cb56453 100644 --- a/fix/fixer_qemu_host_port.go +++ b/fix/fixer_qemu_host_port.go @@ -56,6 +56,8 @@ func (FixerQEMUHostPort) Synopsis() string { return `Updates ssh_host_port_min and ssh_host_port_max to host_port_min and host_port_max` } -func (FixerQEMUHostPort) DeprecatedOptions() []string { - return []string{"ssh_host_port_max", "ssh_host_port_min"} +func (FixerQEMUHostPort) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "transcend.qemu": []string{"ssh_host_port_max", "ssh_host_port_min"}, + } } diff --git a/fix/fixer_scaleway_access_key.go b/fix/fixer_scaleway_access_key.go index 3cbc13669..cad7ec65b 100644 --- a/fix/fixer_scaleway_access_key.go +++ b/fix/fixer_scaleway_access_key.go @@ -8,8 +8,10 @@ import ( // to "organization_id". type FixerScalewayAccessKey struct{} -func (FixerScalewayAccessKey) DeprecatedOptions() []string { - return []string{"access_key"} +func (FixerScalewayAccessKey) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "hashicorp.scaleway": []string{"access_key"}, + } } func (FixerScalewayAccessKey) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_ssh_timeout.go b/fix/fixer_ssh_timeout.go index 3e9c3c2e9..bb5f4a4e2 100644 --- a/fix/fixer_ssh_timeout.go +++ b/fix/fixer_ssh_timeout.go @@ -7,8 +7,10 @@ import ( // FixerSSHTimout replaces ssh_wait_timeout with ssh_timeout type FixerSSHTimout struct{} -func (FixerSSHTimout) DeprecatedOptions() []string { - return []string{"ssh_wait_timeout"} +func (FixerSSHTimout) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"ssh_wait_timeout"}, + } } func (FixerSSHTimout) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_sshdisableagent.go b/fix/fixer_sshdisableagent.go index 4cfc05aa6..833bca027 100644 --- a/fix/fixer_sshdisableagent.go +++ b/fix/fixer_sshdisableagent.go @@ -8,8 +8,10 @@ import ( // to "ssh_disable_agent_forwarding". type FixerSSHDisableAgent struct{} -func (FixerSSHDisableAgent) DeprecatedOptions() []string { - return []string{"ssh_disable_agent"} +func (FixerSSHDisableAgent) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"ssh_disable_agent"}, + } } func (FixerSSHDisableAgent) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_sshkeypath.go b/fix/fixer_sshkeypath.go index d624cc828..9b376261d 100644 --- a/fix/fixer_sshkeypath.go +++ b/fix/fixer_sshkeypath.go @@ -8,8 +8,10 @@ import ( // to "ssh_private_key_file". type FixerSSHKeyPath struct{} -func (FixerSSHKeyPath) DeprecatedOptions() []string { - return []string{"ssh_key_path"} +func (FixerSSHKeyPath) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "*": []string{"ssh_key_path"}, + } } func (FixerSSHKeyPath) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_virtualbox_gaattach.go b/fix/fixer_virtualbox_gaattach.go index dc46bf2fb..8e2a85e85 100644 --- a/fix/fixer_virtualbox_gaattach.go +++ b/fix/fixer_virtualbox_gaattach.go @@ -8,8 +8,10 @@ import ( // to "guest_additions_mode". type FixerVirtualBoxGAAttach struct{} -func (FixerVirtualBoxGAAttach) DeprecatedOptions() []string { - return []string{"guest_additions_attach"} +func (FixerVirtualBoxGAAttach) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "mitchellh.virtualbox": []string{"guest_additions_attach"}, + } } func (FixerVirtualBoxGAAttach) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_virtualbox_rename.go b/fix/fixer_virtualbox_rename.go index 6e1698fa4..2f118e3fb 100644 --- a/fix/fixer_virtualbox_rename.go +++ b/fix/fixer_virtualbox_rename.go @@ -7,8 +7,8 @@ import ( // FixerVirtualBoxRename changes "virtualbox" builders to "virtualbox-iso" type FixerVirtualBoxRename struct{} -func (FixerVirtualBoxRename) DeprecatedOptions() []string { - return []string{} +func (FixerVirtualBoxRename) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerVirtualBoxRename) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_vmware_compaction.go b/fix/fixer_vmware_compaction.go index fcc2813fd..dfb1d1354 100644 --- a/fix/fixer_vmware_compaction.go +++ b/fix/fixer_vmware_compaction.go @@ -7,8 +7,8 @@ import ( // FixerVMwareCompaction adds "skip_compaction = true" to "vmware-iso" builders with incompatible disk_type_id type FixerVMwareCompaction struct{} -func (FixerVMwareCompaction) DeprecatedOptions() []string { - return []string{} +func (FixerVMwareCompaction) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerVMwareCompaction) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_vmware_rename.go b/fix/fixer_vmware_rename.go index 165fb29b0..726e8030c 100644 --- a/fix/fixer_vmware_rename.go +++ b/fix/fixer_vmware_rename.go @@ -7,8 +7,8 @@ import ( // FixerVMwareRename changes "vmware" builders to "vmware-iso" type FixerVMwareRename struct{} -func (FixerVMwareRename) DeprecatedOptions() []string { - return []string{} +func (FixerVMwareRename) DeprecatedOptions() map[string][]string { + return map[string][]string{} } func (FixerVMwareRename) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/fix/fixer_vsphere_network_storage.go b/fix/fixer_vsphere_network_storage.go index ff29ec520..5c04ab1a3 100644 --- a/fix/fixer_vsphere_network_storage.go +++ b/fix/fixer_vsphere_network_storage.go @@ -9,9 +9,11 @@ import ( // disk_eagerly_scrub into a storage adapter type FixerVSphereNetworkDisk struct{} -func (FixerVSphereNetworkDisk) DeprecatedOptions() []string { - return []string{"network_card", "network", "networkCard", "disk_size", - "disk_thin_provisioned", "disk_eagerly_scrub"} +func (FixerVSphereNetworkDisk) DeprecatedOptions() map[string][]string { + return map[string][]string{ + "jetbrains.vsphere": []string{"network_card", "network", "networkCard", "disk_size", + "disk_thin_provisioned", "disk_eagerly_scrub"}, + } } func (FixerVSphereNetworkDisk) Fix(input map[string]interface{}) (map[string]interface{}, error) { diff --git a/go.mod b/go.mod index a7a5ce40e..3d2c7049b 100644 --- a/go.mod +++ b/go.mod @@ -93,6 +93,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-testing-interface v1.0.3 // indirect github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed + github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/mapstructure v1.2.3 github.com/mitchellh/panicwrap v1.0.0 @@ -111,6 +112,7 @@ require ( github.com/pkg/sftp v0.0.0-20160118190721-e84cc8c755ca github.com/posener/complete v1.2.3 github.com/profitbricks/profitbricks-sdk-go v4.0.2+incompatible + github.com/ryanuber/go-glob v1.0.0 github.com/satori/go.uuid v1.2.0 // indirect github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7 github.com/shirou/gopsutil v2.18.12+incompatible diff --git a/go.sum b/go.sum index 1c0a21f59..b92b448d9 100644 --- a/go.sum +++ b/go.sum @@ -377,6 +377,7 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= @@ -511,6 +512,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= diff --git a/helper/config/decode.go b/helper/config/decode.go index 66eb02d53..6a4065ef5 100644 --- a/helper/config/decode.go +++ b/helper/config/decode.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/template/interpolate" "github.com/mitchellh/mapstructure" + "github.com/ryanuber/go-glob" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" ctyjson "github.com/zclconf/go-cty/cty/json" @@ -30,6 +31,11 @@ type DecodeOpts struct { InterpolateContext *interpolate.Context InterpolateFilter *interpolate.RenderFilter + // PluginType is the BuilderID, etc of the plugin -- it is used to + // determine whether to tell the user to "fix" their template if an + // unknown option is a deprecated one for this plugin type. + PluginType string + DecodeHooks []mapstructure.DecodeHookFunc } @@ -43,6 +49,7 @@ var DefaultDecodeHookFuncs = []mapstructure.DecodeHookFunc{ // Decode decodes the configuration into the target and optionally // automatically interpolates all the configuration as it goes. func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error { + // loop over raws once to get cty values from hcl, if that's a thing. for i, raw := range raws { // check for cty values and transform them to json then to a // map[string]interface{} so that mapstructure can do its thing. @@ -85,6 +92,9 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error { p.Set(reflect.Zero(p.Type())) } } + + // Now perform the normal decode. + if config == nil { config = &DecodeOpts{Interpolate: true} } @@ -138,30 +148,44 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error { if err != nil { return err } + + // In practice, raws is two interfaces: one containing all the packer config + // vars, and one containing the raw json configuration for a single + // plugin. for _, raw := range raws { if err := decoder.Decode(raw); err != nil { return err } - } + // If we have unused keys, it is an error + if len(md.Unused) > 0 { + var err error + sort.Strings(md.Unused) + for _, unused := range md.Unused { + if unused == "type" || strings.HasPrefix(unused, "packer_") { + continue + } - // Set the metadata if it is set - if config.Metadata != nil { - *config.Metadata = md - } - - // If we have unused keys, it is an error - if len(md.Unused) > 0 { - var err error - sort.Strings(md.Unused) - for _, unused := range md.Unused { - if unused != "type" && !strings.HasPrefix(unused, "packer_") { // Check for whether the key is handled in a packer fix // call. fixable := false - for _, deprecatedOption := range DeprecatedOptions { - if unused == deprecatedOption { - fixable = true - break + + // check whether the deprecation option can be fixed using packer fix. + if config.PluginType != "" { + for k, deprecatedOptions := range DeprecatedOptions { + // the deprecated options keys are globbable, for + // example "amazon*" for all amazon builders, or * for + // all builders + if glob.Glob(k, config.PluginType) { + for _, deprecatedOption := range deprecatedOptions { + if unused == deprecatedOption { + fixable = true + break + } + } + } + if fixable == true { + break + } } } @@ -179,10 +203,15 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error { err = multierror.Append(err, unusedErr) } + if err != nil { + return err + } } - if err != nil { - return err - } + } + + // Set the metadata if it is set + if config.Metadata != nil { + *config.Metadata = md } return nil diff --git a/helper/config/decode_test.go b/helper/config/decode_test.go index b08fb2af1..4bc68d93a 100644 --- a/helper/config/decode_test.go +++ b/helper/config/decode_test.go @@ -2,6 +2,7 @@ package config import ( "reflect" + "strings" "testing" "time" @@ -133,3 +134,73 @@ func TestDecode(t *testing.T) { } } } + +func TestDecode_fixerRecommendations(t *testing.T) { + type TestConfig struct { + Name string + } + + cases := []struct { + Reason string + Input []interface{} + Opts *DecodeOpts + Expected string + }{ + { + Reason: "If no plugin type is provided, don't try to match fixer options", + Input: []interface{}{ + map[string]interface{}{ + "name": "bar", + "iso_md5": "13123412341234", + }, + }, + Opts: &DecodeOpts{}, + Expected: `unknown configuration key: '"iso_md5"'`, + }, + { + Reason: "iso_md5 should always recommend packer fix regardless of plugin type", + Input: []interface{}{ + map[string]interface{}{ + "name": "bar", + "iso_md5": "13123412341234", + }, + }, + Opts: &DecodeOpts{PluginType: "someplugin"}, + Expected: `Deprecated configuration key: 'iso_md5'`, + }, + { + Reason: "filename option should generate a fixer recommendation for the manifest postprocessor", + Input: []interface{}{ + map[string]interface{}{ + "name": "bar", + "filename": "fakefilename", + }, + }, + Opts: &DecodeOpts{PluginType: "packer.post-processor.manifest"}, + Expected: `Deprecated configuration key: 'filename'`, + }, + { + Reason: "filename option should generate an unknown key error for other plugins", + Input: []interface{}{ + map[string]interface{}{ + "name": "bar", + "filename": "fakefilename", + }, + }, + Opts: &DecodeOpts{PluginType: "randomplugin"}, + Expected: `unknown configuration key: '"filename"'`, + }, + } + + for _, tc := range cases { + var result TestConfig + err := Decode(&result, tc.Opts, tc.Input...) + if err == nil { + t.Fatalf("Should have had an error: %s", tc.Reason) + } + + if !strings.Contains(err.Error(), tc.Expected) { + t.Fatalf("Expected: %s\nActual: %s\n; Reason: %s", tc.Expected, err.Error(), tc.Reason) + } + } +} diff --git a/helper/config/deprecated_options.go b/helper/config/deprecated_options.go index 0ad66d740..bb53c7d01 100644 --- a/helper/config/deprecated_options.go +++ b/helper/config/deprecated_options.go @@ -2,43 +2,20 @@ package config -var DeprecatedOptions = []string{ - "iso_md5", - "guest_additions_attach", - "headless", - "parallels_tools_host_path", - "guest_os_distribution", - "ssh_key_path", - "ssh_disable_agent", - "access_key", - "filename", - "shutdown_behaviour", - "enhanced_networking", - "ssh_private_ip", - "temporary_security_group_source_cidr", - "login_email", - "tag", - "vhd_temp_path", - "clone_from_vmxc_path", - "cpu", - "ram_size", - "clean_image_name", - "clean_ami_name", - "spot_price_auto_product", - "galaxycommand", - "ssh_host_port_min", - "ssh_host_port_max", - "ssh_skip_nat_mapping", - "ssh_wait_timeout", - "network_card", - "network", - "networkCard", - "disk_size", - "disk_thin_provisioned", - "disk_eagerly_scrub", - "iso_checksum_url", - "iso_checksum_type", - "ssh_host_port_max", - "ssh_host_port_min", - "exlude_from_latest", +var DeprecatedOptions = map[string][]string{ + "*": []string{"iso_md5", "ssh_key_path", "ssh_disable_agent", "ssh_host_port_min", "ssh_host_port_max", "ssh_skip_nat_mapping", "ssh_wait_timeout", "iso_checksum_url", "iso_checksum_type"}, + "*amazon*": []string{"shutdown_behaviour", "enhanced_networking", "ssh_private_ip", "temporary_security_group_source_cidr", "clean_ami_name", "spot_price_auto_product"}, + "Azure*": []string{"clean_image_name", "exlude_from_latest"}, + "MSOpenTech.hyperv": []string{"vhd_temp_path", "clone_from_vmxc_path", "cpu", "ram_size"}, + "ansible": []string{"galaxycommand"}, + "hashicorp.scaleway": []string{"access_key"}, + "jetbrains.vsphere": []string{"network_card", "network", "networkCard", "disk_size", "disk_thin_provisioned", "disk_eagerly_scrub"}, + "mitchellh.virtualbox": []string{"guest_additions_attach"}, + "packer.docker": []string{"login_email"}, + "packer.googlecompute": []string{"clean_image_name"}, + "packer.parallels": []string{"headless", "parallels_tools_host_path", "guest_os_distribution"}, + "packer.post-processor.docker-import": []string{"login_email"}, + "packer.post-processor.docker-tag": []string{"tag"}, + "packer.post-processor.manifest": []string{"filename"}, + "transcend.qemu": []string{"ssh_host_port_max", "ssh_host_port_min"}, } diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index e99069175..67fa91e5f 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -116,6 +116,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 12179b918..51e5eb829 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -59,6 +59,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { p.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/artifice/post-processor.go b/post-processor/artifice/post-processor.go index 361214e1b..9c80aba75 100644 --- a/post-processor/artifice/post-processor.go +++ b/post-processor/artifice/post-processor.go @@ -37,6 +37,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "artifice", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/checksum/post-processor.go b/post-processor/checksum/post-processor.go index a518b265e..ce8496812 100644 --- a/post-processor/checksum/post-processor.go +++ b/post-processor/checksum/post-processor.go @@ -56,6 +56,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "checksum", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index bc690e351..6b84852cb 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -59,6 +59,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "compress", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 7857e5d0f..74b63aec1 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -77,6 +77,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/docker-import/post-processor.go b/post-processor/docker-import/post-processor.go index 2ce178ce0..711ff7af2 100644 --- a/post-processor/docker-import/post-processor.go +++ b/post-processor/docker-import/post-processor.go @@ -35,6 +35,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/docker-push/post-processor.go b/post-processor/docker-push/post-processor.go index 97ffb8627..7c642988f 100644 --- a/post-processor/docker-push/post-processor.go +++ b/post-processor/docker-push/post-processor.go @@ -40,6 +40,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderIdImport, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/docker-save/post-processor.go b/post-processor/docker-save/post-processor.go index 8cf3306d7..db572a200 100644 --- a/post-processor/docker-save/post-processor.go +++ b/post-processor/docker-save/post-processor.go @@ -37,6 +37,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/docker-tag/post-processor.go b/post-processor/docker-tag/post-processor.go index e7ed00c72..466176402 100644 --- a/post-processor/docker-tag/post-processor.go +++ b/post-processor/docker-tag/post-processor.go @@ -39,6 +39,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index fa114c0b1..c2233715b 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -71,6 +71,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, }, raws...) diff --git a/post-processor/googlecompute-import/post-processor.go b/post-processor/googlecompute-import/post-processor.go index 737e64560..e61af45cd 100644 --- a/post-processor/googlecompute-import/post-processor.go +++ b/post-processor/googlecompute-import/post-processor.go @@ -74,6 +74,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index b6d396c2d..a11f308a1 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -51,6 +51,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "manifest", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index 826b54c84..817b54fa6 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -83,7 +83,6 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ - Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ Exclude: []string{ diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index b79652a67..8a46b321c 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -63,6 +63,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index 42edf9b80..bc3e314f5 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -56,6 +56,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: vsphere.BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index c57a9e704..b816f31cb 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -64,6 +64,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index b2e88df66..3e995f480 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -65,6 +65,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index dfbee192a..a4913eebb 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -67,6 +67,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap func (p *PostProcessor) Configure(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index dff05a861..75338465d 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -82,6 +82,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "ansible-local", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 6ff90ea86..a82aab702 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -223,6 +223,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.done = make(chan struct{}) err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "ansible", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index b38d1ab9f..5772b98d1 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -74,6 +74,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { // WinRMPassword: `{{.WinRMPassword}}`, // } err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "azure-dtlartifact", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index fa96e544b..d1674bf1a 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -32,6 +32,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "breakpoint", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index c2feca22b..60f13fa14 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -126,6 +126,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "chef-client", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index feb0a9505..402ff73b9 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -106,6 +106,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "chef-solo", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index 3cfff2540..47aa4843d 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -63,6 +63,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode( &p.config, &config.DecodeOpts{ + PluginType: "converge", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 45a1f6618..3b25a1df6 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -68,6 +68,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "file", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 438321689..0644663ff 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -75,6 +75,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.done = make(chan struct{}) err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "inspec", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 70b7105da..e7524b79a 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -117,6 +117,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "powershell", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 4e62e842d..1c1307edd 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -155,6 +155,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "puppet-masterless", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index 71826831b..6025e7998 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -149,6 +149,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "puppet-server", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index d99effd18..d343e3ef5 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -118,6 +118,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "salt-masterless", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 6fea2ba90..b66a6d793 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -75,6 +75,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "shell", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index bf44a2830..8fc800ed8 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -68,6 +68,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "windows-restart", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 3cc15bf92..e081c7151 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -55,6 +55,7 @@ func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapst func (p *Provisioner) Prepare(raws ...interface{}) error { err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: "windows-shell", Interpolate: true, InterpolateContext: &p.config.ctx, InterpolateFilter: &interpolate.RenderFilter{