post-processor/vagrant: provider-specific config works
This commit is contained in:
parent
f035b7a08d
commit
8e46cd5c22
|
@ -41,31 +41,29 @@ func (p *PostProcessor) Configure(raw interface{}) error {
|
|||
return fmt.Errorf("output invalid template: %s", err)
|
||||
}
|
||||
|
||||
/*
|
||||
TODO(mitchellh): We need a way to get the keys...
|
||||
mapConfig, ok := raw.(map[string]interface{})
|
||||
if !ok {
|
||||
panic("Raw configuration not a map")
|
||||
var mapConfig map[string]interface{}
|
||||
if err := mapstructure.Decode(raw, &mapConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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)
|
||||
for k, raw := range mapConfig {
|
||||
pp := keyToPostProcessor(k)
|
||||
if pp == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := pp.Configure(raw); err != nil {
|
||||
errors = append(errors, err)
|
||||
}
|
||||
|
||||
p.premade[k] = pp
|
||||
if err := pp.Configure(raw); err != nil {
|
||||
errors = append(errors, err)
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
return &packer.MultiError{errors}
|
||||
}
|
||||
*/
|
||||
p.premade[k] = pp
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
return &packer.MultiError{errors}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -35,3 +35,15 @@ func TestBuilderPrepare_OutputPath(t *testing.T) {
|
|||
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