Rename variable

This commit is contained in:
Darren Shepherd 2020-02-10 20:54:33 -07:00
parent 433a39dcab
commit 3a8e216ec8
3 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@ func (a *AccessSet) Namespaces() (result []string) {
continue
}
for access := range as {
if access.Namespace == all {
if access.Namespace == All {
continue
}
set[access.Namespace] = true
@ -60,9 +60,9 @@ func (a *AccessSet) Merge(right *AccessSet) {
func (a AccessSet) AccessListFor(verb string, gr schema.GroupResource) (result AccessList) {
dedup := map[Access]bool{}
for _, v := range []string{all, verb} {
for _, g := range []string{all, gr.Group} {
for _, r := range []string{all, gr.Resource} {
for _, v := range []string{All, verb} {
for _, g := range []string{All, gr.Group} {
for _, r := range []string{All, gr.Resource} {
for k := range a.set[key{
verb: v,
gr: schema.GroupResource{
@ -105,7 +105,7 @@ func (a AccessListByVerb) Grants(verb, namespace, name string) bool {
}
func (a AccessListByVerb) All(verb string) bool {
return a.Grants(verb, all, all)
return a.Grants(verb, All, All)
}
type Resources struct {
@ -125,7 +125,7 @@ func (a AccessListByVerb) Granted(verb string) (result map[string]Resources) {
for _, verb := range verbs {
for _, access := range a[verb] {
resources := result[access.Namespace]
if access.ResourceName == all {
if access.ResourceName == All {
resources.All = true
} else {
if resources.Names == nil {
@ -170,11 +170,11 @@ func (a Access) Grants(namespace, name string) bool {
}
func (a Access) nsOK(namespace string) bool {
return a.Namespace == all || a.Namespace == namespace
return a.Namespace == All || a.Namespace == namespace
}
func (a Access) nameOK(name string) bool {
return a.ResourceName == all || a.ResourceName == name
return a.ResourceName == All || a.ResourceName == name
}
func GetAccessListMap(s *types.APISchema) AccessListByVerb {

View File

@ -8,7 +8,7 @@ import (
const (
rbacGroup = "rbac.authorization.k8s.io"
all = "*"
All = "*"
)
type policyRuleIndex struct {
@ -102,7 +102,7 @@ func (p *policyRuleIndex) addAccess(accessSet *AccessSet, namespace string, role
for _, resource := range rule.Resources {
names := rule.ResourceNames
if len(names) == 0 {
names = []string{all}
names = []string{All}
}
for _, resourceName := range names {
for _, verb := range rule.Verbs {

View File

@ -86,7 +86,7 @@ func (c *Collection) schemasForSubject(access *accesscontrol.AccessSet) (*types.
var accessList accesscontrol.AccessList
for _, ns := range access.Namespaces() {
accessList = append(accessList, accesscontrol.Access{
Namespace: "*",
Namespace: accesscontrol.All,
ResourceName: ns,
})
}