Skip to content

Commit 3416524

Browse files
committed
Fix order of last used at
1 parent 275a1c0 commit 3416524

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/cmd/token/token.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TokenCmd(ch *cmdutil.Helper) *cobra.Command {
4949
type ServiceToken struct {
5050
ID string `header:"id" json:"id"`
5151
Name string `header:"name" json:"name"`
52-
LastUsedAt *int64 `header:"last_used_at,timestamp(ms|utc|human)" json:"last_used_at"`
52+
LastUsedAt int64 `header:"last_used_at,timestamp(ms|utc|human)" json:"last_used_at"`
5353
CreatedAt int64 `header:"created_at,timestamp(ms|utc|human)" json:"created_at"`
5454

5555
orig *ps.ServiceToken
@@ -67,11 +67,18 @@ func toServiceToken(st *ps.ServiceToken) *ServiceToken {
6767
name = *st.Name
6868
}
6969

70+
// Avoid using GetMillisecondsIfExists as the table printer
71+
// will not order the columns correctly if lastUsedAt is *int64
72+
var lastUsedAt int64
73+
if st.LastUsedAt != nil {
74+
lastUsedAt = printer.GetMilliseconds(*st.LastUsedAt)
75+
}
76+
7077
return &ServiceToken{
7178
ID: st.ID,
7279
Name: name,
80+
LastUsedAt: lastUsedAt,
7381
CreatedAt: printer.GetMilliseconds(st.CreatedAt),
74-
LastUsedAt: printer.GetMillisecondsIfExists(st.LastUsedAt),
7582
orig: st,
7683
}
7784
}

0 commit comments

Comments
 (0)