Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions api/v1/postgres_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package v1

import (
"fmt"
"reflect"

"regexp"

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
}
Expand Down