mirror of
https://github.com/juanfont/headscale.git
synced 2026-09-30 20:09:36 +09:00
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:
committed by
Kristoffer Dalby
parent
fbb04c5611
commit
715c5a4a1c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user