func (privileges *Privileges) getObjectPrivileges(obj Base) *Privilege {
	var result *Privilege
	if obj.GetNamespace() == runtime.SystemNS {
		result = privileges.GlobalObjects[obj.GetKind()]
	} else {
		result = privileges.NamespaceObjects[obj.GetKind()]
	}
	if result == nil {
		return noAccess
	}
	return result
}
Returns privileges for a given object
package lang
import (
	"sort"
	"github.com/Aptomi/aptomi/pkg/lang/expression"
	"github.com/Aptomi/aptomi/pkg/runtime"
)
const namespaceAll = "*"
type ACLRule struct {
	runtime.TypeKind `yaml:",inline"`
	Metadata         `validate:"required"`
	Weight int `validate:"min=0"`
	Criteria *Criteria `yaml:",omitempty" validate:"omitempty"`
	Actions *ACLRuleActions `validate:"required"`
}
var TypeACLRule = &runtime.TypeInfo{
	Kind:        "aclrule",
	Storable:    true,
	Versioned:   true,
	Constructor: func() runtime.Object { return &ACLRule{} },
}
func (aclRule *ACLRule) Matches(params *expression.Parameters, cache *expression.Cache) (bool, error) {
	if aclRule.Criteria == nil {
		return true, nil
	}
	return aclRule.Criteria.allows(params, cache)
}
type aclRuleSorter []*ACLRule
func (rs aclRuleSorter) Len() int {
	return len(rs)
}
func (rs aclRuleSorter) Swap(i, j int) {
	rs[i], rs[j] = rs[j], rs[i]
}
func (rs aclRuleSorter) Less(i, j int) bool {
	return rs[i].Weight < rs[j].Weight
}
func GetACLRulesSortedByWeight(rules map[string]*ACLRule) []*ACLRule {
	result := []*ACLRule{}
	for _, rule := range rules {
		result = append(result, rule)
	}
	sort.Sort(aclRuleSorter(result))
	return result
}
type ACLRole struct {
	ID         string
	Name       string
	Privileges *Privileges
}
type Privileges struct {
	AllNamespaces bool
	NamespaceObjects map[string]*Privilege
	GlobalObjects map[string]*Privilege
}