making pgTeamMap a pointer

This commit is contained in:
Felix Kunde
2021-02-04 16:50:21 +01:00
parent 2c3cd3ae02
commit 9e2cea54ab
5 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ var (
type Config struct {
OpConfig config.Config
RestConfig *rest.Config
PgTeamMap pgteams.PostgresTeamMap
PgTeamMap *pgteams.PostgresTeamMap
InfrastructureRoles map[string]spec.PgUser // inherited from the controller
PodServiceAccount *v1.ServiceAccount
PodServiceAccountRoleBinding *rbacv1.RoleBinding
+2
View File
@@ -8,6 +8,7 @@ import (
"github.com/sirupsen/logrus"
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando/postgres-operator/pkg/spec"
pgteams "github.com/zalando/postgres-operator/pkg/teams"
"github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
@@ -37,6 +38,7 @@ var cl = New(
DownscalerAnnotations: []string{"downscaler/*"},
},
},
PgTeamMap: new(pgteams.PostgresTeamMap),
},
k8sutil.NewMockKubernetesClient(),
acidv1.Postgresql{ObjectMeta: metav1.ObjectMeta{Name: "acid-test", Namespace: "test", Annotations: map[string]string{"downscaler/downtime_replicas": "0"}}},
+8 -1
View File
@@ -240,7 +240,14 @@ func (c *Cluster) getTeamMembers(teamID string) ([]string, error) {
c.logger.Debugf("fetching possible additional team members for team %q", teamID)
members := []string{}
additionalMembers := c.PgTeamMap[teamID].AdditionalMembers
additionalMembers := []string{}
for team, membership := range *c.PgTeamMap {
if team == teamID {
additionalMembers = membership.AdditionalMembers
}
}
for _, member := range additionalMembers {
members = append(members, member)
}