bump pooler image and more coalescing for CRD config (#1004)

Co-authored-by: Felix Kunde <felix.kunde@zalando.de>
This commit is contained in:
Felix Kunde
2020-06-05 11:14:17 +02:00
committed by GitHub
co-authored by Felix Kunde
parent 9acdcd8bbf
commit 3c352fb460
13 changed files with 136 additions and 39 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ type Config struct {
EnablePodDisruptionBudget *bool `name:"enable_pod_disruption_budget" default:"true"`
EnableInitContainers *bool `name:"enable_init_containers" default:"true"`
EnableSidecars *bool `name:"enable_sidecars" default:"true"`
Workers uint32 `name:"workers" default:"4"`
Workers uint32 `name:"workers" default:"8"`
APIPort int `name:"api_port" default:"8080"`
RingLogLines int `name:"ring_log_lines" default:"100"`
ClusterHistoryEntries int `name:"cluster_history_entries" default:"1000"`
+44
View File
@@ -147,6 +147,30 @@ func Coalesce(val, defaultVal string) string {
return val
}
// CoalesceStrArr returns the first argument if it is not null, otherwise the second one.
func CoalesceStrArr(val, defaultVal []string) []string {
if len(val) == 0 {
return defaultVal
}
return val
}
// CoalesceStrMap returns the first argument if it is not null, otherwise the second one.
func CoalesceStrMap(val, defaultVal map[string]string) map[string]string {
if len(val) == 0 {
return defaultVal
}
return val
}
// CoalesceInt works like coalesce but for int
func CoalesceInt(val, defaultVal int) int {
if val == 0 {
return defaultVal
}
return val
}
// CoalesceInt32 works like coalesce but for *int32
func CoalesceInt32(val, defaultVal *int32) *int32 {
if val == nil {
@@ -155,6 +179,14 @@ func CoalesceInt32(val, defaultVal *int32) *int32 {
return val
}
// CoalesceUInt32 works like coalesce but for uint32
func CoalesceUInt32(val, defaultVal uint32) uint32 {
if val == 0 {
return defaultVal
}
return val
}
// CoalesceBool works like coalesce but for *bool
func CoalesceBool(val, defaultVal *bool) *bool {
if val == nil {
@@ -163,6 +195,18 @@ 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 {
duration, err := time.ParseDuration(defaultVal)
if err != nil {
panic(err)
}
return duration
}
return val
}
// Test if any of the values is nil
func testNil(values ...*int32) bool {
for _, v := range values {