From db20985b068544f27cd6f2d946bfc90def0b72db Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 11 Jul 2021 13:14:25 +0200 Subject: [PATCH] Show N/A in reusable when key is ephemeral --- cmd/headscale/cli/preauthkeys.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/headscale/cli/preauthkeys.go b/cmd/headscale/cli/preauthkeys.go index e9b61fa0..d59b0759 100644 --- a/cmd/headscale/cli/preauthkeys.go +++ b/cmd/headscale/cli/preauthkeys.go @@ -44,11 +44,19 @@ var ListPreAuthKeys = &cobra.Command{ if k.Expiration != nil { expiration = k.Expiration.Format("2006-01-02 15:04:05") } + + var reusable string + if k.Ephemeral { + reusable = "N/A" + } else { + reusable = fmt.Sprintf("%v", k.Reusable) + } + fmt.Printf( - "key: %s, namespace: %s, reusable: %v, ephemeral: %v, expiration: %s, created_at: %s\n", + "key: %s, namespace: %s, reusable: %s, ephemeral: %v, expiration: %s, created_at: %s\n", k.Key, k.Namespace.Name, - k.Reusable, + reusable, k.Ephemeral, expiration, k.CreatedAt.Format("2006-01-02 15:04:05"),