MCPcopy Index your code
hub / github.com/coder/coder / DeduplicatePermissions

Function DeduplicatePermissions

coderd/rbac/roles.go:948–963  ·  view source on GitHub ↗

DeduplicatePermissions removes duplicate Permission entries while preserving the original order of the first occurrence for deterministic evaluation.

(perms []Permission)

Source from the content-addressed store, hash-verified

946// DeduplicatePermissions removes duplicate Permission entries while preserving
947// the original order of the first occurrence for deterministic evaluation.
948func DeduplicatePermissions(perms []Permission) []Permission {
949 if len(perms) == 0 {
950 return perms
951 }
952 seen := make(map[string]struct{}, len(perms))
953 deduped := make([]Permission, 0, len(perms))
954 for _, perm := range perms {
955 key := perm.ResourceType + "\x00" + string(perm.Action) + "\x00" + strconv.FormatBool(perm.Negate)
956 if _, ok := seen[key]; ok {
957 continue
958 }
959 seen[key] = struct{}{}
960 deduped = append(deduped, perm)
961 }
962 return deduped
963}
964
965// PermissionsEqual compares two permission slices as sets. Order and
966// duplicate entries do not matter; it only checks that both slices

Callers 2

expandRBACScopeMethod · 0.92

Calls

no outgoing calls

Tested by 1