making pgTeamMap a pointer
This commit is contained in:
parent
2c3cd3ae02
commit
9e2cea54ab
|
|
@ -49,7 +49,7 @@ var (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
OpConfig config.Config
|
OpConfig config.Config
|
||||||
RestConfig *rest.Config
|
RestConfig *rest.Config
|
||||||
PgTeamMap pgteams.PostgresTeamMap
|
PgTeamMap *pgteams.PostgresTeamMap
|
||||||
InfrastructureRoles map[string]spec.PgUser // inherited from the controller
|
InfrastructureRoles map[string]spec.PgUser // inherited from the controller
|
||||||
PodServiceAccount *v1.ServiceAccount
|
PodServiceAccount *v1.ServiceAccount
|
||||||
PodServiceAccountRoleBinding *rbacv1.RoleBinding
|
PodServiceAccountRoleBinding *rbacv1.RoleBinding
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||||
"github.com/zalando/postgres-operator/pkg/spec"
|
"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/config"
|
||||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||||
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
||||||
|
|
@ -37,6 +38,7 @@ var cl = New(
|
||||||
DownscalerAnnotations: []string{"downscaler/*"},
|
DownscalerAnnotations: []string{"downscaler/*"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PgTeamMap: new(pgteams.PostgresTeamMap),
|
||||||
},
|
},
|
||||||
k8sutil.NewMockKubernetesClient(),
|
k8sutil.NewMockKubernetesClient(),
|
||||||
acidv1.Postgresql{ObjectMeta: metav1.ObjectMeta{Name: "acid-test", Namespace: "test", Annotations: map[string]string{"downscaler/downtime_replicas": "0"}}},
|
acidv1.Postgresql{ObjectMeta: metav1.ObjectMeta{Name: "acid-test", Namespace: "test", Annotations: map[string]string{"downscaler/downtime_replicas": "0"}}},
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,14 @@ func (c *Cluster) getTeamMembers(teamID string) ([]string, error) {
|
||||||
|
|
||||||
c.logger.Debugf("fetching possible additional team members for team %q", teamID)
|
c.logger.Debugf("fetching possible additional team members for team %q", teamID)
|
||||||
members := []string{}
|
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 {
|
for _, member := range additionalMembers {
|
||||||
members = append(members, member)
|
members = append(members, member)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import (
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
config spec.ControllerConfig
|
config spec.ControllerConfig
|
||||||
opConfig *config.Config
|
opConfig *config.Config
|
||||||
pgTeamMap teams.PostgresTeamMap
|
pgTeamMap *teams.PostgresTeamMap
|
||||||
|
|
||||||
logger *logrus.Entry
|
logger *logrus.Entry
|
||||||
KubeClient k8sutil.KubernetesClient
|
KubeClient k8sutil.KubernetesClient
|
||||||
|
|
@ -332,7 +332,7 @@ func (c *Controller) initController() {
|
||||||
if c.opConfig.EnablePostgresTeamCRD {
|
if c.opConfig.EnablePostgresTeamCRD {
|
||||||
c.loadPostgresTeams()
|
c.loadPostgresTeams()
|
||||||
} else {
|
} else {
|
||||||
c.pgTeamMap = teams.PostgresTeamMap{}
|
c.pgTeamMap = new(teams.PostgresTeamMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.opConfig.DebugLogging {
|
if c.opConfig.DebugLogging {
|
||||||
|
|
|
||||||
|
|
@ -396,7 +396,7 @@ func (c *Controller) getInfrastructureRole(
|
||||||
|
|
||||||
func (c *Controller) loadPostgresTeams() {
|
func (c *Controller) loadPostgresTeams() {
|
||||||
// reset team map
|
// reset team map
|
||||||
c.pgTeamMap = teams.PostgresTeamMap{}
|
c.pgTeamMap = new(teams.PostgresTeamMap)
|
||||||
|
|
||||||
pgTeams, err := c.KubeClient.PostgresTeamsGetter.PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{})
|
pgTeams, err := c.KubeClient.PostgresTeamsGetter.PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue