cli: split the user lookup out of resolveSingleUser

Lets commands with their own flags resolve a user the same way.
This commit is contained in:
Kristoffer Dalby authored and Kristoffer Dalby committed 2026-09-28 21:42:19 +02:00
1 parent fbb04c5611
commit 715c5a4a1c
1 file changed
+11
+11
View File
@@ -64,6 +64,17 @@ func resolveSingleUser(
return "", nil, err
}
return lookupUser(ctx, client, id, username)
}
// lookupUser resolves exactly one user by ID and/or name (0 and "" are unset),
// returning the identifier of the matched user and the user itself.
func lookupUser(
ctx context.Context,
client *clientv1.ClientWithResponses,
id uint64,
username string,
) (string, *clientv1.User, error) {
params := &clientv1.ListUsersParams{}
if username != "" {
params.Name = &username