sort service role actions on init
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"go.infratographer.com/x/gidx"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"go.equinixmetal.net/infra9-metal-bridge/internal/metal"
|
||||
"go.equinixmetal.net/infra9-metal-bridge/internal/permissions"
|
||||
@@ -64,7 +65,13 @@ func WithRootTenant(sid string) Option {
|
||||
// WithRoles defines the role to action mapping.
|
||||
func WithRoles(roles map[string][]string) Option {
|
||||
return func(s *service) error {
|
||||
s.roles = roles
|
||||
s.roles = make(map[string][]string, len(roles))
|
||||
|
||||
for role, actions := range roles {
|
||||
slices.Sort(actions)
|
||||
|
||||
s.roles[role] = actions
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user