From b971b70cb24117e2820f84bd9efc24c7f0266d41 Mon Sep 17 00:00:00 2001 From: "Lim, Kian-An" Date: Wed, 3 Mar 2021 14:37:10 +0100 Subject: [PATCH 1/2] Consider value nil with type, e.g. []string(nil) --- api/v1/postgres_types.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/v1/postgres_types.go b/api/v1/postgres_types.go index 0fd4ede7..a7b0aed7 100644 --- a/api/v1/postgres_types.go +++ b/api/v1/postgres_types.go @@ -8,6 +8,7 @@ package v1 import ( "fmt" + "reflect" "regexp" @@ -418,7 +419,7 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql) (*unst // Delete unused fields deleteIfEmpty(jsonSpec, "clone") - deleteIfEmpty(jsonSpec, "patroni") + deleteIfEmpty(jsonSpec, "patroni") // if in use, deleteIfEmpty needs to consider the case of struct. deleteIfEmpty(jsonSpec, "podAnnotations") deleteIfEmpty(jsonSpec, "serviceAnnotations") deleteIfEmpty(jsonSpec, "standby") @@ -473,7 +474,10 @@ func removeElem(ss []string, s string) (out []string) { } func deleteIfEmpty(json map[string]interface{}, key string) { - if json[key] == nil { + i := json[key] + + // interface has type and value. The chained function calls deal with nil value with type. + if i == nil || reflect.ValueOf(json[key]).IsNil() { delete(json, key) } } From 06321fdeafb79f7c2a0f654ffd3640140f883f38 Mon Sep 17 00:00:00 2001 From: "Lim, Kian-An" Date: Wed, 3 Mar 2021 22:55:00 +0100 Subject: [PATCH 2/2] Fix `make deploy` glitch --- config/manager/configmap.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/manager/configmap.yaml b/config/manager/configmap.yaml index b65ae571..ac1767ae 100644 --- a/config/manager/configmap.yaml +++ b/config/manager/configmap.yaml @@ -6,8 +6,8 @@ data: PARTITION_ID: sample-partition TENANT: sample-tenant LOAD_BALANCER_IP: "127.0.0.1" - PORT_RANGE_START: 32000 - PORT_RANGE_SIZE: 8000 + PORT_RANGE_START: "32000" + PORT_RANGE_SIZE: "8000" kind: ConfigMap metadata: creationTimestamp: null