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)
| 966 | // duplicate entries do not matter; it only checks that both slices |
| 967 | // contain the same unique permissions. |
| 968 | func 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 |
no outgoing calls