mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
- add proper parsing of CheckType.Timeout from string
This commit is contained in:
parent
e87afe341b
commit
7f91782478
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user