Skip to content

Commit 63d2cfd

Browse files
committed
Fix oc policy remove-user to remove rolebindings too
Followup to openshift#18102 Signed-off-by: Simo Sorce <[email protected]>
1 parent 073bb37 commit 63d2cfd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/oc/admin/policy/remove_from_project.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ func (o *RemoveFromProjectOptions) Run() error {
176176
}
177177

178178
if !o.DryRun {
179-
_, err = o.Client.RoleBindings(o.BindingNamespace).Update(&currBinding)
179+
if len(currBinding.Subjects) > 0 {
180+
_, err = o.Client.RoleBindings(o.BindingNamespace).Update(&currBinding)
181+
} else {
182+
_, err = o.Client.RoleBindings(o.BindingNamespace).Delete(currBinding.Name, &metav1.DeleteOptions{})
183+
}
180184
if err != nil {
181185
return err
182186
}

0 commit comments

Comments
 (0)