mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 07:44:26 +02:00
refactoring
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
// 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
|
||||
AdditionalTeams []string
|
||||
AdditionalMembers []string
|
||||
@@ -115,15 +115,10 @@ func (ptm *PostgresTeamMap) Load(pgTeams *acidv1.PostgresTeamList) {
|
||||
fetchTeams(&teamIDs, teamMemberSet)
|
||||
|
||||
for teamID := range teamIDs {
|
||||
(*ptm)[teamID] = &PostgresTeamMembership{
|
||||
(*ptm)[teamID] = &postgresTeamMembership{
|
||||
AdditionalSuperuserTeams: util.CoalesceStrArr(superuserTeamSet.toMap()[teamID], []string{}),
|
||||
AdditionalTeams: util.CoalesceStrArr(teamSet.toMap()[teamID], []string{}),
|
||||
AdditionalMembers: util.CoalesceStrArr(teamMemberSet.toMap()[teamID], []string{}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset a PostgresTeamMap
|
||||
func (ptm *PostgresTeamMap) Reset() {
|
||||
*ptm = emptyTeamMap
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package teams
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||
"github.com/zalando/postgres-operator/pkg/util"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -109,14 +108,6 @@ func TestLoadingPostgresTeamCRD(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLoadingPostgresTeamCRD PostgresTeamMap is the operator's internal representation of all PostgresTeam CRDs
|
||||
func TestResetPostgresTeamCRD(t *testing.T) {
|
||||
teamMap := &pgTeamMap
|
||||
teamMap.Reset()
|
||||
|
||||
assert.Equal(t, teamMap, &PostgresTeamMap{})
|
||||
}
|
||||
|
||||
// TestGetAdditionalTeams if returns teams with and without transitive dependencies
|
||||
func TestGetAdditionalTeams(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user