From 951fd5a8e778253d33240651d83a48ccc5f1c059 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Tue, 20 Jan 2026 09:42:23 +0000 Subject: [PATCH] cli: show Owner column in preauthkeys list Replace the Tags column with an Owner column that displays: - Tags (newline-separated) if the key has ACL tags - User name if the key is associated with a user - Dash (-) if neither is present This aligns the CLI output with the tags-as-identity model where preauthkeys can be created with either tags or user ownership. --- cmd/headscale/cli/preauthkeys.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/headscale/cli/preauthkeys.go b/cmd/headscale/cli/preauthkeys.go index 498cfe4d..51133200 100644 --- a/cmd/headscale/cli/preauthkeys.go +++ b/cmd/headscale/cli/preauthkeys.go @@ -78,7 +78,7 @@ var listPreAuthKeys = &cobra.Command{ "Used", "Expiration", "Created", - "Tags", + "Owner", }, } for _, key := range response.GetPreAuthKeys() { @@ -87,14 +87,15 @@ var listPreAuthKeys = &cobra.Command{ expiration = ColourTime(key.GetExpiration().AsTime()) } - aclTags := "" - - for _, tag := range key.GetAclTags() { - aclTags += "\n" + tag + var owner string + if len(key.GetAclTags()) > 0 { + owner = strings.Join(key.GetAclTags(), "\n") + } else if key.GetUser() != nil { + owner = key.GetUser().GetName() + } else { + owner = "-" } - aclTags = strings.TrimLeft(aclTags, "\n") - tableData = append(tableData, []string{ strconv.FormatUint(key.GetId(), 10), key.GetKey(), @@ -103,7 +104,7 @@ var listPreAuthKeys = &cobra.Command{ strconv.FormatBool(key.GetUsed()), expiration, key.GetCreatedAt().AsTime().Format("2006-01-02 15:04:05"), - aclTags, + owner, }) }