post-processor/vagrant: provider-specific config works
This commit is contained in:
parent
21ae9a02d6
commit
bc9a09e3fc
|
@ -41,31 +41,29 @@ func (p *PostProcessor) Configure(raw interface{}) error {
|
||||||
return fmt.Errorf("output invalid template: %s", err)
|
return fmt.Errorf("output invalid template: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
var mapConfig map[string]interface{}
|
||||||
TODO(mitchellh): We need a way to get the keys...
|
if err := mapstructure.Decode(raw, &mapConfig); err != nil {
|
||||||
mapConfig, ok := raw.(map[string]interface{})
|
return err
|
||||||
if !ok {
|
}
|
||||||
panic("Raw configuration not a map")
|
|
||||||
|
p.premade = make(map[string]packer.PostProcessor)
|
||||||
|
errors := make([]error, 0)
|
||||||
|
for k, raw := range mapConfig {
|
||||||
|
pp := keyToPostProcessor(k)
|
||||||
|
if pp == nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
errors := make([]error, 0)
|
if err := pp.Configure(raw); err != nil {
|
||||||
for k, raw := range mapConfig {
|
errors = append(errors, err)
|
||||||
pp := keyToPostProcessor(k)
|
|
||||||
if pp == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := pp.Configure(raw); err != nil {
|
|
||||||
errors = append(errors, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.premade[k] = pp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errors) > 0 {
|
p.premade[k] = pp
|
||||||
return &packer.MultiError{errors}
|
}
|
||||||
}
|
|
||||||
*/
|
if len(errors) > 0 {
|
||||||
|
return &packer.MultiError{errors}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,3 +35,15 @@ func TestBuilderPrepare_OutputPath(t *testing.T) {
|
||||||
t.Fatal("should have error")
|
t.Fatal("should have error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuilderPrepare_PPConfig(t *testing.T) {
|
||||||
|
var p PostProcessor
|
||||||
|
|
||||||
|
// Default
|
||||||
|
c := testConfig()
|
||||||
|
c["aws"] = map[string]interface{}{}
|
||||||
|
err := p.Configure(c)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue