mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-23 02:24:10 +00:00
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.
This commit is contained in:
parent
b8f3e09046
commit
951fd5a8e7
1 changed files with 9 additions and 8 deletions
|
|
@ -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,
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue