common: weakly decode the PackerConfig

This commit is contained in:
Mitchell Hashimoto 2014-04-26 14:23:22 -07:00
parent ce7ea006c7
commit 5dec2ddb9c
1 changed files with 10 additions and 1 deletions

View File

@ -191,8 +191,17 @@ func decodeConfigHook(raws []interface{}) (mapstructure.DecodeHookFunc, error) {
// First thing we do is decode PackerConfig so that we can have access // First thing we do is decode PackerConfig so that we can have access
// to the user variables so that we can process some templates. // to the user variables so that we can process some templates.
var pc PackerConfig var pc PackerConfig
decoderConfig := &mapstructure.DecoderConfig{
Result: &pc,
WeaklyTypedInput: true,
}
decoder, err := mapstructure.NewDecoder(decoderConfig)
if err != nil {
return nil, err
}
for _, raw := range raws { for _, raw := range raws {
if err := mapstructure.Decode(raw, &pc); err != nil { if err := decoder.Decode(raw); err != nil {
return nil, err return nil, err
} }
} }