MCPcopy Create free account
hub / github.com/coder/coder / PermissionsEqual

Function PermissionsEqual

coderd/rbac/roles.go:968–983  ·  view source on GitHub ↗

PermissionsEqual compares two permission slices as sets. Order and duplicate entries do not matter; it only checks that both slices contain the same unique permissions.

(a, b []Permission)

Source from the content-addressed store, hash-verified

966// duplicate entries do not matter; it only checks that both slices
967// contain the same unique permissions.
968func PermissionsEqual(a, b []Permission) bool {
969 setA := make(map[Permission]struct{}, len(a))
970 for _, p := range a {
971 setA[p] = struct{}{}
972 }
973
974 setB := make(map[Permission]struct{}, len(b))
975 for _, p := range b {
976 if _, ok := setA[p]; !ok {
977 return false
978 }
979 setB[p] = struct{}{}
980 }
981
982 return len(setA) == len(setB)
983}
984
985// OrgSettings carries organization-level settings that affect system
986// role permissions. It lives in the rbac package to avoid a cyclic

Callers 4

TestReconcileSystemRoleFunction · 0.92
TestReconcileSystemRolesFunction · 0.92
ReconcileSystemRoleFunction · 0.92
TestPermissionsEqualFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestReconcileSystemRoleFunction · 0.74
TestReconcileSystemRolesFunction · 0.74
TestPermissionsEqualFunction · 0.68