Permissions is just a helper function to make building roles that list out resources and actions a bit easier.
(perms map[string][]policy.Action)
| 926 | // Permissions is just a helper function to make building roles that list out resources |
| 927 | // and actions a bit easier. |
| 928 | func Permissions(perms map[string][]policy.Action) []Permission { |
| 929 | list := make([]Permission, 0, len(perms)) |
| 930 | for k, actions := range perms { |
| 931 | for _, act := range actions { |
| 932 | list = append(list, Permission{ |
| 933 | Negate: false, |
| 934 | ResourceType: k, |
| 935 | Action: act, |
| 936 | }) |
| 937 | } |
| 938 | } |
| 939 | // Deterministic ordering of permissions |
| 940 | sort.Slice(list, func(i, j int) bool { |
| 941 | return list[i].ResourceType < list[j].ResourceType |
| 942 | }) |
| 943 | return list |
| 944 | } |
| 945 | |
| 946 | // DeduplicatePermissions removes duplicate Permission entries while preserving |
| 947 | // the original order of the first occurrence for deterministic evaluation. |
no outgoing calls