refactroing part 2
This commit is contained in:
parent
27ec82bd85
commit
b261f6b8c0
|
|
@ -1143,7 +1143,7 @@ func (c *Cluster) initHumanUsers() error {
|
|||
var clusterIsOwnedBySuperuserTeam bool
|
||||
superuserTeams := []string{}
|
||||
|
||||
if c.OpConfig.EnablePostgresTeamCRDSuperusers {
|
||||
if c.OpConfig.EnablePostgresTeamCRD && c.OpConfig.EnablePostgresTeamCRDSuperusers && c.Config.PgTeamMap != nil {
|
||||
superuserTeams = c.Config.PgTeamMap.GetAdditionalSuperuserTeams(c.Spec.TeamID, true)
|
||||
}
|
||||
|
||||
|
|
@ -1163,7 +1163,7 @@ func (c *Cluster) initHumanUsers() error {
|
|||
}
|
||||
}
|
||||
|
||||
if c.Config.PgTeamMap != nil {
|
||||
if c.OpConfig.EnablePostgresTeamCRD && c.Config.PgTeamMap != nil {
|
||||
additionalTeams := c.Config.PgTeamMap.GetAdditionalTeams(c.Spec.TeamID, true)
|
||||
for _, additionalTeam := range additionalTeams {
|
||||
if !(util.SliceContains(superuserTeams, additionalTeam)) {
|
||||
|
|
|
|||
|
|
@ -329,10 +329,9 @@ func (c *Controller) initController() {
|
|||
|
||||
c.initSharedInformers()
|
||||
|
||||
c.pgTeamMap = teams.PostgresTeamMap{}
|
||||
if c.opConfig.EnablePostgresTeamCRD {
|
||||
c.loadPostgresTeams()
|
||||
} else {
|
||||
c.pgTeamMap = teams.PostgresTeamMap{}
|
||||
}
|
||||
|
||||
if c.opConfig.DebugLogging {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ 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"
|
||||
|
|
@ -395,9 +394,6 @@ func (c *Controller) getInfrastructureRole(
|
|||
}
|
||||
|
||||
func (c *Controller) loadPostgresTeams() {
|
||||
// reset team map
|
||||
c.pgTeamMap = teams.PostgresTeamMap{}
|
||||
|
||||
pgTeams, err := c.KubeClient.PostgresTeamsGetter.PostgresTeams(c.opConfig.WatchedNamespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
c.logger.Errorf("could not list postgres team objects: %v", err)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import (
|
|||
// PostgresTeamMap is the operator's internal representation of all PostgresTeam CRDs
|
||||
type PostgresTeamMap map[string]*postgresTeamMembership
|
||||
|
||||
var emptyTeamMap = make(PostgresTeamMap, 0)
|
||||
|
||||
type postgresTeamMembership struct {
|
||||
AdditionalSuperuserTeams []string
|
||||
AdditionalTeams []string
|
||||
|
|
@ -96,9 +94,8 @@ func (ptm *PostgresTeamMap) GetAdditionalSuperuserTeams(team string, transitive
|
|||
|
||||
// Load function to import data from PostgresTeam CRD
|
||||
func (ptm *PostgresTeamMap) Load(pgTeams *acidv1.PostgresTeamList) {
|
||||
if ptm == nil {
|
||||
ptm = &emptyTeamMap
|
||||
}
|
||||
var emptyTeamMap = make(PostgresTeamMap, 0)
|
||||
*ptm = emptyTeamMap
|
||||
|
||||
superuserTeamSet := teamHashSet{}
|
||||
teamSet := teamHashSet{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue