mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 08:55:43 +03:00
Create a weak decoder to parse time.Duration.
Hat tip to Alex for pointing this out (vs patching mapstructure)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user