Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions contrib/completions/bash/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions contrib/completions/zsh/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/man/man1/.files_generated_oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-adm-prune-auth.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions hack/import-restrictions.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@
"vendor/k8s.io/kubernetes/pkg/printers",
"vendor/k8s.io/kubernetes/pkg/util",
"vendor/k8s.io/utils",
"vendor/github.com/davecgh/go-spew/spew",

"github.com/openshift/origin/pkg/apps/generated",
"github.com/openshift/origin/pkg/authorization/generated",
Expand Down Expand Up @@ -457,7 +458,7 @@
"github.com/openshift/origin/pkg/apps/client/v1",
"github.com/openshift/origin/pkg/apps/util",
"github.com/openshift/origin/pkg/authorization/apis/authorization",
"github.com/openshift/origin/pkg/authorization/reaper",
"github.com/openshift/origin/pkg/authorization/apis/authorization/install",
"github.com/openshift/origin/pkg/authorization/registry/util",
"github.com/openshift/origin/pkg/authorization/util",
"github.com/openshift/origin/pkg/build/apis/build",
Expand Down Expand Up @@ -525,7 +526,6 @@
"github.com/openshift/origin/pkg/unidling/util",
"github.com/openshift/origin/pkg/user/apis/user",
"github.com/openshift/origin/pkg/user/apis/user/install",
"github.com/openshift/origin/pkg/user/reaper",
"github.com/openshift/origin/pkg/util",
"github.com/openshift/origin/pkg/util/docker/dockerfile",
"github.com/openshift/origin/pkg/util/dot",
Expand Down
61 changes: 0 additions & 61 deletions pkg/authorization/reaper/cluster_role.go

This file was deleted.

47 changes: 0 additions & 47 deletions pkg/authorization/reaper/role.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package reaper
package authprune

import (
"github.com/golang/glog"
"fmt"
"io"

kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kapi "k8s.io/kubernetes/pkg/apis/core"
Expand All @@ -10,10 +12,12 @@ import (
)

// reapClusterBindings removes the subject from cluster-level role bindings
func reapClusterBindings(removedSubject kapi.ObjectReference, c authclient.Interface) error {
func reapClusterBindings(removedSubject kapi.ObjectReference, c authclient.Interface, out io.Writer) []error {
errors := []error{}

clusterBindings, err := c.Authorization().ClusterRoleBindings().List(metav1.ListOptions{})
if err != nil {
return err
return []error{err}
}
for _, binding := range clusterBindings.Items {
retainedSubjects := []kapi.ObjectReference{}
Expand All @@ -26,18 +30,22 @@ func reapClusterBindings(removedSubject kapi.ObjectReference, c authclient.Inter
updatedBinding := binding
updatedBinding.Subjects = retainedSubjects
if _, err := c.Authorization().ClusterRoleBindings().Update(&updatedBinding); err != nil && !kerrors.IsNotFound(err) {
glog.Infof("Cannot update clusterrolebinding/%s: %v", binding.Name, err)
errors = append(errors, err)
} else {
fmt.Fprintf(out, "clusterrolebinding.rbac.authorization.k8s.io/"+updatedBinding.Name+" updated\n")
}
}
}
return nil
return errors
}

// reapNamespacedBindings removes the subject from namespaced role bindings
func reapNamespacedBindings(removedSubject kapi.ObjectReference, c authclient.Interface) error {
func reapNamespacedBindings(removedSubject kapi.ObjectReference, c authclient.Interface, out io.Writer) []error {
errors := []error{}

namespacedBindings, err := c.Authorization().RoleBindings(metav1.NamespaceAll).List(metav1.ListOptions{})
if err != nil {
return err
return []error{err}
}
for _, binding := range namespacedBindings.Items {
retainedSubjects := []kapi.ObjectReference{}
Expand All @@ -50,9 +58,11 @@ func reapNamespacedBindings(removedSubject kapi.ObjectReference, c authclient.In
updatedBinding := binding
updatedBinding.Subjects = retainedSubjects
if _, err := c.Authorization().RoleBindings(binding.Namespace).Update(&updatedBinding); err != nil && !kerrors.IsNotFound(err) {
glog.Infof("Cannot update rolebinding/%s in %s: %v", binding.Name, binding.Namespace, err)
errors = append(errors, err)
} else {
fmt.Fprintf(out, "rolebinding.rbac.authorization.k8s.io/"+updatedBinding.Name+" updated\n")
}
}
}
return nil
return errors
}
Loading