diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 667d9ba95..03bc2911c 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -37,7 +37,7 @@ import ( type Controller struct { config spec.ControllerConfig opConfig *config.Config - pgTeamMap *teams.PostgresTeamMap + pgTeamMap teams.PostgresTeamMap logger *logrus.Entry KubeClient k8sutil.KubernetesClient diff --git a/pkg/controller/util.go b/pkg/controller/util.go index ed770935c..8c8fcf223 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -15,6 +15,7 @@ import ( acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" "github.com/zalando/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/teams" "github.com/zalando/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/k8sutil" @@ -30,7 +31,7 @@ func (c *Controller) makeClusterConfig() cluster.Config { return cluster.Config{ RestConfig: c.config.RestConfig, OpConfig: config.Copy(c.opConfig), - PgTeamMap: c.pgTeamMap, + PgTeamMap: &c.pgTeamMap, InfrastructureRoles: infrastructureRoles, PodServiceAccount: c.PodServiceAccount, } @@ -395,7 +396,7 @@ func (c *Controller) getInfrastructureRole( func (c *Controller) loadPostgresTeams() { // reset team map - c.pgTeamMap.Reset() + c.pgTeamMap = teams.PostgresTeamMap{} pgTeams, err := c.KubeClient.PostgresTeamsGetter.PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{}) if err != nil { diff --git a/pkg/teams/postgres_team.go b/pkg/teams/postgres_team.go index 0f835862b..21d3f7656 100644 --- a/pkg/teams/postgres_team.go +++ b/pkg/teams/postgres_team.go @@ -125,7 +125,5 @@ func (ptm *PostgresTeamMap) Load(pgTeams *acidv1.PostgresTeamList) { // Reset a PostgresTeamMap func (ptm *PostgresTeamMap) Reset() { - if ptm != nil { - *ptm = emptyTeamMap - } + *ptm = emptyTeamMap }