mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 15:16:28 +02:00
switch to metav1.Duration for timeout options (#3121)
* switch to metav1.Duration for timeout options * fix custom config parsing and use safe coalesce
This commit is contained in:
+4
-4
@@ -311,14 +311,14 @@ func CoalesceBool(val, defaultVal *bool) *bool {
|
||||
return val
|
||||
}
|
||||
|
||||
// CoalesceDuration works like coalesce but for time.Duration
|
||||
func CoalesceDuration(val time.Duration, defaultVal string) time.Duration {
|
||||
if val == 0 {
|
||||
// CoalesceDuration works like coalesce but for metav1.Duration
|
||||
func CoalesceDuration(val *metav1.Duration, defaultVal string) *metav1.Duration {
|
||||
if val == nil || val.Duration == 0 {
|
||||
duration, err := time.ParseDuration(defaultVal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return duration
|
||||
return &metav1.Duration{Duration: duration}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user