Create a weak decoder to parse time.Duration.

Hat tip to Alex for pointing this out (vs patching mapstructure)
This commit is contained in:
Sean Chittenden
2016-05-27 11:47:52 -07:00
parent 6cdc0556de
commit d6769f59f7

View File

@@ -624,7 +624,15 @@ func parseConsulConfig(result **config.ConsulConfig, list *ast.ObjectList) error
}
var consulConfig config.ConsulConfig
if err := mapstructure.WeakDecode(m, &consulConfig); err != nil {
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
WeaklyTypedInput: true,
Result: &consulConfig,
})
if err != nil {
return err
}
if err := dec.Decode(m); err != nil {
return err
}