- 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

View File

@ -644,7 +644,7 @@ AFTER_FIX:
} }
func FixupCheckType(raw interface{}) error { func FixupCheckType(raw interface{}) error {
var ttlKey, intervalKey string var ttlKey, intervalKey, timeoutKey string
// Handle decoding of time durations // Handle decoding of time durations
rawMap, ok := raw.(map[string]interface{}) rawMap, ok := raw.(map[string]interface{})
@ -658,6 +658,8 @@ func FixupCheckType(raw interface{}) error {
ttlKey = k ttlKey = k
case "interval": case "interval":
intervalKey = k intervalKey = k
case "timeout":
timeoutKey = k
case "service_id": case "service_id":
rawMap["serviceid"] = v rawMap["serviceid"] = v
delete(rawMap, "service_id") 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 return nil
} }