Merge pull request #75264 from smarterclayton/optimize_rbac_visit

Avoid allocating when performing VisitRulesFor on service accounts
This commit is contained in:
Kubernetes Prow Robot
2019-03-20 19:19:35 -07:00
committed by GitHub
3 changed files with 62 additions and 2 deletions

View File

@@ -286,7 +286,8 @@ func appliesToUser(user user.Info, subject rbacv1.Subject, namespace string) boo
if len(saNamespace) == 0 {
return false
}
return serviceaccount.MakeUsername(saNamespace, subject.Name) == user.GetName()
// use a more efficient comparison for RBAC checking
return serviceaccount.MatchesUsername(saNamespace, subject.Name, user.GetName())
default:
return false
}