From 79f00ea8f328db6a6f69f1e02fbfc81c557471d9 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Fri, 4 Dec 2020 15:29:51 +0100 Subject: [PATCH] return nil if no annotations are set --- pkg/cluster/util.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/util.go b/pkg/cluster/util.go index 0f17af88f..8004af175 100644 --- a/pkg/cluster/util.go +++ b/pkg/cluster/util.go @@ -276,6 +276,8 @@ func (c *Cluster) getTeamMembers(teamID string) ([]string, error) { // when listing k8s objects. See operator PR #252 func (c *Cluster) annotationsSet(annotations map[string]string) map[string]string { + var result map[string]string + // allow to inherit certain labels from the 'postgres' object if spec, err := c.GetSpec(); err == nil { for k, v := range spec.ObjectMeta.Annotations { @@ -289,7 +291,11 @@ func (c *Cluster) annotationsSet(annotations map[string]string) map[string]strin c.logger.Warningf("could not get the list of InheritedAnnoations for cluster %q: %v", c.Name, err) } - return annotations + if len(annotations) > 0 { + result = annotations + } + + return result } func (c *Cluster) waitForPodLabel(podEvents chan PodEvent, stopChan chan struct{}, role *PostgresRole) (*v1.Pod, error) {