- add proper parsing of CheckType.Timeout from string

This commit is contained in:
arnaud briche 2015-02-02 15:29:42 +07:00
parent e87afe341b
commit 7f91782478
1 changed files with 15 additions and 1 deletions

View File

@ -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
}