From 7f917824789c5305c638c0a2f8d923af17018ece Mon Sep 17 00:00:00 2001 From: arnaud briche Date: Mon, 2 Feb 2015 15:29:42 +0700 Subject: [PATCH] - add proper parsing of CheckType.Timeout from string --- command/agent/config.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/command/agent/config.go b/command/agent/config.go index 208daf5640..6f457aa054 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -644,7 +644,7 @@ AFTER_FIX: } func FixupCheckType(raw interface{}) error { - var ttlKey, intervalKey string + var ttlKey, intervalKey, timeoutKey string // Handle decoding of time durations rawMap, ok := raw.(map[string]interface{}) @@ -658,6 +658,8 @@ func FixupCheckType(raw interface{}) error { ttlKey = k case "interval": intervalKey = k + case "timeout": + timeoutKey = k case "service_id": rawMap["serviceid"] = v delete(rawMap, "service_id") @@ -685,6 +687,18 @@ func FixupCheckType(raw interface{}) error { } } } + + if timeout, ok := rawMap[timeoutKey]; ok { + timeoutS, ok := timeout.(string) + if ok { + if dur, err := time.ParseDuration(timeoutS); err != nil { + return err + } else { + rawMap[timeoutKey] = dur + } + } + } + return nil }