Skip to content

Commit 6f4e8ac

Browse files
committed
feat: add support of granting membership on roles
1 parent 9a4430d commit 6f4e8ac

14 files changed

+268
-37
lines changed

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ resources:
1616
kind: PostgresDatabase
1717
path: github.com/hoppscale/managed-postgres-operator/api/v1alpha1
1818
version: v1alpha1
19+
- api:
20+
crdVersion: v1
21+
namespaced: true
22+
controller: true
23+
domain: managed-postgres-operator.hoppscale.com
24+
kind: PostgresRole
25+
path: github.com/hoppscale/managed-postgres-operator/api/v1alpha1
26+
version: v1alpha1
1927
version: "3"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ spec:
3737
replication: false # Is the role used for replication?
3838
bypassRLS: false # Should the role bypass the defined row-level security (RLS) policies?
3939
passwordSecretName: "my-secret" # Name of the secret from where the role's password should be retrieved under the key `password`
40+
memberOfRoles: # List of roles the role should be member of
41+
- anotherRole
4042
```

api/v1alpha1/postgresrole_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type PostgresRoleSpec struct {
3636
BypassRLS bool `json:"bypassRLS,omitempty"`
3737

3838
PasswordSecretName string `json:"passwordSecretName,omitempty"`
39+
40+
MemberOfRoles []string `json:"memberOfRoles,omitempty"`
3941
}
4042

4143
// PostgresRoleStatus defines the observed state of PostgresRole.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/managed-postgres-operator.hoppscale.com_postgresroles.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ spec:
4949
type: boolean
5050
login:
5151
type: boolean
52+
memberOfRoles:
53+
items:
54+
type: string
55+
type: array
5256
name:
5357
description: PostgreSQL role name
5458
type: string

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# It should be run by config/default
44
resources:
55
- bases/managed-postgres-operator.hoppscale.com_postgresdatabases.yaml
6+
- bases/managed-postgres-operator.hoppscale.com_postgresroles.yaml
67
# +kubebuilder:scaffold:crdkustomizeresource
78

89
patches:

config/rbac/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ resources:
55
# runtime. Be sure to update RoleBinding and ClusterRoleBinding
66
# subjects if changing service account names.
77
- service_account.yaml
8-
- role.yaml
98
- role_binding.yaml
109
- leader_election_role.yaml
1110
- leader_election_role_binding.yaml

config/rbac/role.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/onsi/gomega v1.37.0
1414
github.com/pashagolub/pgxmock/v4 v4.7.0
1515
go.uber.org/zap v1.27.0
16+
k8s.io/api v0.32.4
1617
k8s.io/apimachinery v0.32.4
1718
k8s.io/client-go v0.32.4
1819
sigs.k8s.io/controller-runtime v0.20.4
@@ -96,7 +97,6 @@ require (
9697
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9798
gopkg.in/inf.v0 v0.9.1 // indirect
9899
gopkg.in/yaml.v3 v3.0.1 // indirect
99-
k8s.io/api v0.32.4 // indirect
100100
k8s.io/apiextensions-apiserver v0.32.4 // indirect
101101
k8s.io/apiserver v0.32.4 // indirect
102102
k8s.io/component-base v0.32.4 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
5252
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
5353
github.com/google/cel-go v0.22.1 h1:AfVXx3chM2qwoSbM7Da8g8hX8OVSkBFwX+rz2+PcK40=
5454
github.com/google/cel-go v0.22.1/go.mod h1:BuznPXXfQDpXKWQ9sPW3TzlAJN5zzFe+i9tIs0yC4s8=
55-
github.com/google/cel-go v0.25.0 h1:jsFw9Fhn+3y2kBbltZR4VEz5xKkcIFRPDnuEzAGv5GY=
56-
github.com/google/cel-go v0.25.0/go.mod h1:hjEb6r5SuOSlhCHmFoLzu8HGCERvIsDAbxDAyNU/MmI=
5755
github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw=
5856
github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw=
5957
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=

0 commit comments

Comments
 (0)