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
2026-09-28 13:34:18 +00:00
committed by Kristoffer Dalby
parent fbb04c5611
commit 715c5a4a1c
+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