fix: clusterrolebinding controller bug

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2020-05-29 12:49:28 +08:00
parent 1882b20e6e
commit 4e418bbe03
7 changed files with 67 additions and 49 deletions

View File

@@ -334,8 +334,12 @@ func (am *amOperator) ListRoleBindings(username, namespace string) ([]*rbacv1.Ro
}
func contains(subjects []rbacv1.Subject, username string) bool {
// if username is nil means list all role bindings
if username == "" {
return true
}
for _, subject := range subjects {
if subject.Kind == rbacv1.UserKind && (username == "" || subject.Name == username) {
if subject.Kind == rbacv1.UserKind && subject.Name == username {
return true
}
}