From fa90283781bc2f53b8f01592d65f1c7221632998 Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Sun, 17 May 2026 06:37:42 +0200 Subject: [PATCH] Extract wildcard user merge helper to satisfy case-clause length --- .../server/types/policy_authorized_users.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/management/server/types/policy_authorized_users.go b/management/server/types/policy_authorized_users.go index c56a689ca..c2363fffc 100644 --- a/management/server/types/policy_authorized_users.go +++ b/management/server/types/policy_authorized_users.go @@ -62,12 +62,16 @@ func applyResolvedRuleToState( return } state.sshEnabled = true - if state.authorizedUsers[auth.Wildcard] == nil { - state.authorizedUsers[auth.Wildcard] = make(map[string]struct{}) - } - for userID := range cb.getAllowedUserIDs() { - state.authorizedUsers[auth.Wildcard][userID] = struct{}{} - } + mergeWildcardUsers(state.authorizedUsers, cb.getAllowedUserIDs()) + } +} + +func mergeWildcardUsers(dst map[string]map[string]struct{}, users map[string]struct{}) { + if dst[auth.Wildcard] == nil { + dst[auth.Wildcard] = make(map[string]struct{}) + } + for userID := range users { + dst[auth.Wildcard][userID] = struct{}{} } }