diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 10f3a47f7..799ae51f2 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -580,6 +580,7 @@ func (c *Config) createCertificate() (string, error) { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.ctx.Funcs = azcommon.TemplateFuncs err := config.Decode(c, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, }, raws...) diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index 5009a5bab..d46cd82dc 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -389,6 +389,7 @@ func newConfig(raws ...interface{}) (*Config, []string, error) { var c Config c.ctx.Funcs = TemplateFuncs err := config.Decode(&c, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, }, raws...) diff --git a/builder/docker/config.go b/builder/docker/config.go index d04ce88f9..aa0b785e4 100644 --- a/builder/docker/config.go +++ b/builder/docker/config.go @@ -127,6 +127,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { var md mapstructure.Metadata err := config.Decode(c, &config.DecodeOpts{ Metadata: &md, + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index f10caaf4f..aea8e36a1 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -291,6 +291,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { c.ctx.Funcs = TemplateFuncs err := config.Decode(c, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/parallels/pvm/config.go b/builder/parallels/pvm/config.go index 4f88ee193..bd9b421f6 100644 --- a/builder/parallels/pvm/config.go +++ b/builder/parallels/pvm/config.go @@ -51,6 +51,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: parallelscommon.BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/qemu/config.go b/builder/qemu/config.go index 081087ecf..1af05df37 100644 --- a/builder/qemu/config.go +++ b/builder/qemu/config.go @@ -394,6 +394,7 @@ type Config struct { func (c *Config) Prepare(raws ...interface{}) ([]string, error) { err := config.Decode(c, &config.DecodeOpts{ + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index 6844cffab..c88e4fea5 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -99,6 +99,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { var md mapstructure.Metadata err := config.Decode(c, &config.DecodeOpts{ Metadata: &md, + PluginType: BuilderId, Interpolate: true, InterpolateContext: &c.ctx, InterpolateFilter: &interpolate.RenderFilter{ diff --git a/go.mod b/go.mod index 3d2c7049b..e67ef5261 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,6 @@ 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 diff --git a/go.sum b/go.sum index b92b448d9..1c0a21f59 100644 --- a/go.sum +++ b/go.sum @@ -377,7 +377,6 @@ 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= @@ -512,8 +511,6 @@ 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 6a4065ef5..e351d20d0 100644 --- a/helper/config/decode.go +++ b/helper/config/decode.go @@ -156,56 +156,57 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error { 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 - } + } - // Check for whether the key is handled in a packer fix - // call. - fixable := false - - // 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 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 + } + + // Check for whether the key is handled in a packer fix + // call. + fixable := false + + // 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 - } + } + if fixable == true { + break } } + } - unusedErr := fmt.Errorf("unknown configuration key: '%q'", - unused) - - if fixable { - unusedErr = fmt.Errorf("Deprecated configuration key: '%s'."+ - " Please call `packer fix` against your template to "+ - "update your template to be compatible with the current "+ - "version of Packer. Visit "+ - "https://www.packer.io/docs/commands/fix/ for more detail.", - unused) - } + unusedErr := fmt.Errorf("unknown configuration key: '%q'", + unused) - err = multierror.Append(err, unusedErr) - } - if err != nil { - return err + if fixable { + unusedErr = fmt.Errorf("Deprecated configuration key: '%s'."+ + " Please call `packer fix` against your template to "+ + "update your template to be compatible with the current "+ + "version of Packer. Visit "+ + "https://www.packer.io/docs/commands/fix/ for more detail.", + unused) } + + err = multierror.Append(err, unusedErr) + } + if err != nil { + return err } } diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index a11f308a1..c723d17fd 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -51,7 +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", + PluginType: "packer.post-processor.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 817b54fa6..276ab907a 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -83,6 +83,8 @@ 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{ Exclude: []string{