From 3d7edf19bebbcae0af307f948b3f2b8d2fdf09a1 Mon Sep 17 00:00:00 2001 From: Todd Date: Wed, 22 May 2024 16:30:12 +0000 Subject: [PATCH] backport of commit 6936a5448c3b6ed787b097d1186a4e63a81d9f8c --- .../cmd/commands/clientagentcmd/status.go | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/internal/cmd/commands/clientagentcmd/status.go b/internal/cmd/commands/clientagentcmd/status.go index 745e9b0eff..23130c01c2 100644 --- a/internal/cmd/commands/clientagentcmd/status.go +++ b/internal/cmd/commands/clientagentcmd/status.go @@ -103,13 +103,13 @@ func (c *StatusCommand) Run(args []string) int { } type GetStatusResponse struct { - BoundaryAddr string `json:"boundary_addr"` - AuthTokenId string `json:"auth_token_id"` - AuthTokenExpiry time.Time `json:"auth_token_expiry"` - Version string `json:"version"` - Status string `json:"status"` - Errors []string `json:"errors"` - Warnings []string `json:"warnings"` + BoundaryAddr string `json:"boundary_addr"` + AuthTokenId string `json:"auth_token_id"` + AuthTokenExpiry *time.Time `json:"auth_token_expiry"` + Version string `json:"version"` + Status string `json:"status"` + Errors []string `json:"errors"` + Warnings []string `json:"warnings"` } func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusResponse, *api.Error, error) { @@ -149,11 +149,17 @@ func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusRe func printStatusTable(status *GetStatusResponse) string { nonAttributeMap := map[string]any{ - "Address": status.BoundaryAddr, - "Auth Token Id": status.AuthTokenId, - "Auth Token Expiration": time.Until(status.AuthTokenExpiry).Round(time.Second).String(), - "Version": status.Version, - "Status": status.Status, + "Version": status.Version, + "Status": status.Status, + } + if status.AuthTokenId != "" { + nonAttributeMap["Auth Token Id"] = status.AuthTokenId + } + if status.BoundaryAddr != "" { + nonAttributeMap["Address"] = status.BoundaryAddr + } + if status.AuthTokenExpiry != nil { + nonAttributeMap["Auth Token Expiration"] = time.Until(*status.AuthTokenExpiry).Round(time.Second).String() } maxLength := base.MaxAttributesLength(nonAttributeMap, nil, nil)