Skip to content

Commit

Permalink
Merge pull request #42 from appuio/fix/namespace-owner-reference
Browse files Browse the repository at this point in the history
Fix permission to be able to set owner references
  • Loading branch information
glrf authored Nov 3, 2022
2 parents 7bbf1ac + bb3d7d2 commit 734955a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
Expand Down
6 changes: 4 additions & 2 deletions controllers/org_rbac_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const LabelRoleBindingUninitialized = "appuio.io/uninitialized"
//+kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;patch;update
//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch

// We don't actually want or need to set finalizers, but if "OwnerReferencesPermissionEnforcement" is enabled we need this permission to set an owner reference to a namespace
//+kubebuilder:rbac:groups="",resources=namespaces/finalizers,verbs=update

// Reconcile makes sure the role bindings for the configured cluster roles are present in every organization namespace.
// It will also update role bindings with the label "appuio.io/uninitialized": "true" to the default config.
func (r *OrganizationRBACReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down Expand Up @@ -100,8 +103,7 @@ func (r *OrganizationRBACReconciler) putRoleBinding(ctx context.Context, ns core
}
delete(rb.Labels, LabelRoleBindingUninitialized)
}
controllerutil.SetControllerReference(&ns, rb, r.Scheme)
return nil
return controllerutil.SetControllerReference(&ns, rb, r.Scheme)
})

return err
Expand Down

0 comments on commit 734955a

Please sign in to comment.