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