From d6769f59f7bf56ee895f5c5a4e7c2eb4bb5e644d Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 27 May 2016 11:47:52 -0700 Subject: [PATCH] Create a weak decoder to parse time.Duration. Hat tip to Alex for pointing this out (vs patching mapstructure) --- command/agent/config_parse.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/command/agent/config_parse.go b/command/agent/config_parse.go index 8b4d15046..873752c01 100644 --- a/command/agent/config_parse.go +++ b/command/agent/config_parse.go @@ -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 }