Commit f7585618 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

post-processor/vagrant: don't error if unused

parent 0484006e
...@@ -33,7 +33,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -33,7 +33,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Store the raw configs for usage later // Store the raw configs for usage later
p.rawConfigs = raws p.rawConfigs = raws
md, err := common.DecodeConfig(&p.config, raws...) _, err := common.DecodeConfig(&p.config, raws...)
if err != nil { if err != nil {
return err return err
} }
...@@ -44,20 +44,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -44,20 +44,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
} }
tpl.UserVars = p.config.PackerUserVars tpl.UserVars = p.config.PackerUserVars
// Accumulate any errors // Defaults
errs := common.CheckUnusedConfig(md)
ppExtraConfig := make(map[string]interface{}) ppExtraConfig := make(map[string]interface{})
if p.config.OutputPath == "" { if p.config.OutputPath == "" {
p.config.OutputPath = "packer_{{ .BuildName }}_{{.Provider}}.box" p.config.OutputPath = "packer_{{ .BuildName }}_{{.Provider}}.box"
ppExtraConfig["output"] = p.config.OutputPath ppExtraConfig["output"] = p.config.OutputPath
} }
// _, err := template.New("output").Parse(p.config.OutputPath) // Accumulate any errors
errs := new(packer.MultiError)
if err := tpl.Validate(p.config.OutputPath); err != nil { if err := tpl.Validate(p.config.OutputPath); err != nil {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error parsing output template: %s", err)) errs, fmt.Errorf("Error parsing output template: %s", err))
return errs
} }
// Store the extra configuration for post-processors // Store the extra configuration for post-processors
...@@ -66,11 +64,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -66,11 +64,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// TODO(mitchellh): Properly handle multiple raw configs // TODO(mitchellh): Properly handle multiple raw configs
var mapConfig map[string]interface{} var mapConfig map[string]interface{}
if err := mapstructure.Decode(raws[0], &mapConfig); err != nil { if err := mapstructure.Decode(raws[0], &mapConfig); err != nil {
return err errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Failed to decode config: %s", err))
return errs
} }
p.premade = make(map[string]packer.PostProcessor) p.premade = make(map[string]packer.PostProcessor)
errors := make([]error, 0)
for k, raw := range mapConfig { for k, raw := range mapConfig {
pp := keyToPostProcessor(k) pp := keyToPostProcessor(k)
if pp == nil { if pp == nil {
...@@ -83,14 +82,14 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -83,14 +82,14 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
ppConfigs = append(ppConfigs, raw) ppConfigs = append(ppConfigs, raw)
if err := pp.Configure(ppConfigs...); err != nil { if err := pp.Configure(ppConfigs...); err != nil {
errors = append(errors, err) errs = packer.MultiErrorAppend(errs, err)
} }
p.premade[k] = pp p.premade[k] = pp
} }
if len(errors) > 0 { if len(errs.Errors) > 0 {
return &packer.MultiError{errors} return errs
} }
return nil return nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment