return nil if no annotations are set

This commit is contained in:
Felix Kunde 2020-12-04 15:29:51 +01:00
parent 63e7304a0e
commit 79f00ea8f3
1 changed files with 7 additions and 1 deletions

View File

@ -276,6 +276,8 @@ func (c *Cluster) getTeamMembers(teamID string) ([]string, error) {
// when listing k8s objects. See operator PR #252 // when listing k8s objects. See operator PR #252
func (c *Cluster) annotationsSet(annotations map[string]string) map[string]string { 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 // allow to inherit certain labels from the 'postgres' object
if spec, err := c.GetSpec(); err == nil { if spec, err := c.GetSpec(); err == nil {
for k, v := range spec.ObjectMeta.Annotations { 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) 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) { func (c *Cluster) waitForPodLabel(podEvents chan PodEvent, stopChan chan struct{}, role *PostgresRole) (*v1.Pod, error) {