Skip to content

Commit 070c7d2

Browse files
author
Per Goncalves da Silva
committed
Split rbac phase into two
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent 092099c commit 070c7d2

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

internal/operator-controller/applier/phase.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,22 @@ func determinePhase(gk schema.GroupKind) Phase {
2828
type Phase string
2929

3030
const (
31-
PhaseNamespaces Phase = "namespaces"
32-
PhasePolicies Phase = "policies"
33-
PhaseRBAC Phase = "rbac"
34-
PhaseCRDs Phase = "crds"
35-
PhaseStorage Phase = "storage"
36-
PhaseDeploy Phase = "deploy"
37-
PhasePublish Phase = "publish"
31+
PhaseNamespaces Phase = "namespaces"
32+
PhasePolicies Phase = "policies"
33+
PhaseRBAC Phase = "rbac"
34+
PhaseRBACBindings Phase = "rbac-bindings"
35+
PhaseCRDs Phase = "crds"
36+
PhaseStorage Phase = "storage"
37+
PhaseDeploy Phase = "deploy"
38+
PhasePublish Phase = "publish"
3839
)
3940

4041
// Well known phases ordered.
4142
var defaultPhaseOrder = []Phase{
4243
PhaseNamespaces,
4344
PhasePolicies,
4445
PhaseRBAC,
46+
PhaseRBACBindings,
4547
PhaseCRDs,
4648
PhaseStorage,
4749
PhaseDeploy,
@@ -68,8 +70,11 @@ var (
6870
PhaseRBAC: {
6971
{Kind: "ServiceAccount"},
7072
{Kind: "Role", Group: "rbac.authorization.k8s.io"},
71-
{Kind: "RoleBinding", Group: "rbac.authorization.k8s.io"},
7273
{Kind: "ClusterRole", Group: "rbac.authorization.k8s.io"},
74+
},
75+
76+
PhaseRBACBindings: {
77+
{Kind: "RoleBinding", Group: "rbac.authorization.k8s.io"},
7378
{Kind: "ClusterRoleBinding", Group: "rbac.authorization.k8s.io"},
7479
},
7580

internal/operator-controller/applier/phase_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@ func Test_PhaseSort(t *testing.T) {
8787
},
8888
},
8989
},
90+
{
91+
Object: unstructured.Unstructured{
92+
Object: map[string]interface{}{
93+
"apiVersion": "rbac.authorization.k8s.io/v1",
94+
"kind": "ClusterRoleBinding",
95+
},
96+
},
97+
},
98+
{
99+
Object: unstructured.Unstructured{
100+
Object: map[string]interface{}{
101+
"apiVersion": "rbac.authorization.k8s.io/v1",
102+
"kind": "RoleBinding",
103+
},
104+
},
105+
},
106+
{
107+
Object: unstructured.Unstructured{
108+
Object: map[string]interface{}{
109+
"apiVersion": "rbac.authorization.k8s.io/v1",
110+
"kind": "Role",
111+
},
112+
},
113+
},
90114
{
91115
Object: unstructured.Unstructured{
92116
Object: map[string]interface{}{
@@ -150,6 +174,35 @@ func Test_PhaseSort(t *testing.T) {
150174
},
151175
},
152176
},
177+
{
178+
Object: unstructured.Unstructured{
179+
Object: map[string]interface{}{
180+
"apiVersion": "rbac.authorization.k8s.io/v1",
181+
"kind": "Role",
182+
},
183+
},
184+
},
185+
},
186+
},
187+
{
188+
Name: string(applier.PhaseRBACBindings),
189+
Objects: []v1.ClusterExtensionRevisionObject{
190+
{
191+
Object: unstructured.Unstructured{
192+
Object: map[string]interface{}{
193+
"apiVersion": "rbac.authorization.k8s.io/v1",
194+
"kind": "ClusterRoleBinding",
195+
},
196+
},
197+
},
198+
{
199+
Object: unstructured.Unstructured{
200+
Object: map[string]interface{}{
201+
"apiVersion": "rbac.authorization.k8s.io/v1",
202+
"kind": "RoleBinding",
203+
},
204+
},
205+
},
153206
},
154207
},
155208
{

test/e2e/steps/testdata/rbac-template.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ rules:
5050
- roles
5151
- clusterrolebindings
5252
- rolebindings
53-
# The bind and escalate verbs allow the ServiceAccount to create role bindings
54-
# for roles it doesn't have and grant permissions beyond its own. This is required
55-
# because extension bundles contain their own RBAC that must be created.
56-
# See docs/concepts/permission-model.md for details on these requirements.
57-
verbs: [ update, create, list, watch, get, delete, patch, bind, escalate ]
53+
verbs: [ update, create, list, watch, get, delete, patch ]
5854
- apiGroups: ["coordination.k8s.io"]
5955
resources: ["leases"]
6056
verbs: [ update, create, list, watch, get, delete, patch ]

0 commit comments

Comments
 (0)