polishing and fixes
This commit is contained in:
parent
d246e8492b
commit
c4ee9f9225
|
|
@ -0,0 +1,67 @@
|
|||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: postgresteams.acid.zalan.do
|
||||
labels:
|
||||
app.kubernetes.io/name: postgres-operator
|
||||
annotations:
|
||||
"helm.sh/hook": crd-install
|
||||
spec:
|
||||
group: acid.zalan.do
|
||||
names:
|
||||
kind: PostgresTeam
|
||||
listKind: PostgresTeamList
|
||||
plural: postgresteams
|
||||
singular: postgresteam
|
||||
shortNames:
|
||||
- pgteam
|
||||
scope: Namespaced
|
||||
subresources:
|
||||
status: {}
|
||||
version: v1
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
required:
|
||||
- kind
|
||||
- apiVersion
|
||||
- spec
|
||||
properties:
|
||||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- PostgresTeam
|
||||
apiVersion:
|
||||
type: string
|
||||
enum:
|
||||
- acid.zalan.do/v1
|
||||
spec:
|
||||
type: object
|
||||
properties:
|
||||
additionalSuperuserTeams:
|
||||
type: object
|
||||
description: "Map for teamId and associted additional admin teams"
|
||||
additionalProperties:
|
||||
type: array
|
||||
nullable: true
|
||||
description: "List of teams to become Postgres admins"
|
||||
items:
|
||||
type: string
|
||||
additionalTeams:
|
||||
type: object
|
||||
description: "Map for teamId and associted additional teams"
|
||||
additionalProperties:
|
||||
type: array
|
||||
nullable: true
|
||||
description: "List of teams whose members will also be added to the Postgres cluster"
|
||||
items:
|
||||
type: string
|
||||
additionalMembers:
|
||||
type: object
|
||||
description: "Map for teamId and associted additional users"
|
||||
additionalProperties:
|
||||
type: array
|
||||
nullable: true
|
||||
description: "List of users who will also be added to the Postgres cluster"
|
||||
items:
|
||||
type: string
|
||||
|
|
@ -15,6 +15,7 @@ rules:
|
|||
resources:
|
||||
- postgresqls
|
||||
- postgresqls/status
|
||||
- postgresteams
|
||||
- operatorconfigurations
|
||||
verbs:
|
||||
- create
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
apiVersion: "acid.zalan.do/v1"
|
||||
kind: PostgresTeam
|
||||
metadata:
|
||||
name: custom-team-membership
|
||||
spec:
|
||||
additionalSuperuserTeams:
|
||||
acid:
|
||||
- "postgres_superusers"
|
||||
additionalTeams:
|
||||
acid: []
|
||||
additionalMembers:
|
||||
acid:
|
||||
- "elephant"
|
||||
|
|
@ -16,6 +16,7 @@ rules:
|
|||
resources:
|
||||
- postgresqls
|
||||
- postgresqls/status
|
||||
- postgresteams
|
||||
- operatorconfigurations
|
||||
verbs:
|
||||
- create
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ spec:
|
|||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- postgresteam
|
||||
- PostgresTeam
|
||||
apiVersion:
|
||||
type: string
|
||||
enum:
|
||||
|
|
@ -52,7 +52,7 @@ spec:
|
|||
description: "List of teams whose members will also be added to the Postgres cluster"
|
||||
items:
|
||||
type: string
|
||||
additionalUsers:
|
||||
additionalMembers:
|
||||
type: object
|
||||
description: "Map for teamId and associted additional users"
|
||||
additionalProperties:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
acidzalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do"
|
||||
)
|
||||
|
||||
// APIVersion of the `postgresql` and `operator` CRDs
|
||||
|
|
@ -44,6 +43,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
|||
// TODO: User uppercase CRDResourceKind of our types in the next major API version
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("postgresql"), &Postgresql{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("postgresqlList"), &PostgresqlList{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("PostgresTeam"), &PostgresTeam{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("PostgresTeamList"), &PostgresTeamList{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("OperatorConfiguration"),
|
||||
&OperatorConfiguration{})
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("OperatorConfigurationList"),
|
||||
|
|
|
|||
|
|
@ -242,14 +242,7 @@ func (c *Cluster) getTeamMembers(teamID string) ([]string, error) {
|
|||
}
|
||||
|
||||
for _, member := range teamInfo.Members {
|
||||
contains := false
|
||||
for _, additionalMember := range members {
|
||||
if member == additionalMember {
|
||||
contains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !(contains) {
|
||||
if !(util.SliceContains(members, member)) {
|
||||
members = append(members, member)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ func (c *Controller) getInfrastructureRole(
|
|||
}
|
||||
|
||||
func (c *Controller) loadPostgresTeams(obj interface{}) {
|
||||
var pgTeamMap teams.PostgresTeamMap
|
||||
pgTeamMap := teams.PostgresTeamMap{}
|
||||
|
||||
pgTeam, ok := obj.(*acidv1.PostgresTeam)
|
||||
if !ok {
|
||||
|
|
@ -412,6 +412,7 @@ func (c *Controller) loadPostgresTeams(obj interface{}) {
|
|||
}
|
||||
|
||||
func (c *Controller) updatePostgresTeams(prev, obj interface{}) {
|
||||
c.logger.Debugf("reloading postgres team CRDs and overwriting cached map")
|
||||
c.loadPostgresTeams(obj)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue