mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-23 00:58:43 +02:00
cmd/headscale/cli: use HeadscaleDateTimeFormat and util.Base10 consistently
Replace five hardcoded "2006-01-02 15:04:05" strings with the HeadscaleDateTimeFormat constant already defined in utils.go. Replace two literal 10 base arguments to strconv.FormatUint with util.Base10 to match the convention in api_key.go and nodes.go.
This commit is contained in:
@@ -315,7 +315,7 @@ func nodesToPtables(
|
|||||||
|
|
||||||
if node.GetLastSeen() != nil {
|
if node.GetLastSeen() != nil {
|
||||||
lastSeen = node.GetLastSeen().AsTime()
|
lastSeen = node.GetLastSeen().AsTime()
|
||||||
lastSeenTime = lastSeen.Format("2006-01-02 15:04:05")
|
lastSeenTime = lastSeen.Format(HeadscaleDateTimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -325,7 +325,7 @@ func nodesToPtables(
|
|||||||
|
|
||||||
if node.GetExpiry() != nil {
|
if node.GetExpiry() != nil {
|
||||||
expiry = node.GetExpiry().AsTime()
|
expiry = node.GetExpiry().AsTime()
|
||||||
expiryTime = expiry.Format("2006-01-02 15:04:05")
|
expiryTime = expiry.Format(HeadscaleDateTimeFormat)
|
||||||
} else {
|
} else {
|
||||||
expiryTime = "N/A"
|
expiryTime = "N/A"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
|
"github.com/juanfont/headscale/hscontrol/util"
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -80,13 +81,13 @@ var listPreAuthKeys = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
tableData = append(tableData, []string{
|
tableData = append(tableData, []string{
|
||||||
strconv.FormatUint(key.GetId(), 10),
|
strconv.FormatUint(key.GetId(), util.Base10),
|
||||||
key.GetKey(),
|
key.GetKey(),
|
||||||
strconv.FormatBool(key.GetReusable()),
|
strconv.FormatBool(key.GetReusable()),
|
||||||
strconv.FormatBool(key.GetEphemeral()),
|
strconv.FormatBool(key.GetEphemeral()),
|
||||||
strconv.FormatBool(key.GetUsed()),
|
strconv.FormatBool(key.GetUsed()),
|
||||||
expiration,
|
expiration,
|
||||||
key.GetCreatedAt().AsTime().Format("2006-01-02 15:04:05"),
|
key.GetCreatedAt().AsTime().Format(HeadscaleDateTimeFormat),
|
||||||
owner,
|
owner,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ColourTime(date time.Time) string {
|
func ColourTime(date time.Time) string {
|
||||||
dateStr := date.Format("2006-01-02 15:04:05")
|
dateStr := date.Format(HeadscaleDateTimeFormat)
|
||||||
|
|
||||||
if date.After(time.Now()) {
|
if date.After(time.Now()) {
|
||||||
dateStr = pterm.LightGreen(dateStr)
|
dateStr = pterm.LightGreen(dateStr)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
|
"github.com/juanfont/headscale/hscontrol/util"
|
||||||
"github.com/juanfont/headscale/hscontrol/util/zlog/zf"
|
"github.com/juanfont/headscale/hscontrol/util/zlog/zf"
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@@ -189,11 +190,11 @@ var listUsersCmd = &cobra.Command{
|
|||||||
tableData = append(
|
tableData = append(
|
||||||
tableData,
|
tableData,
|
||||||
[]string{
|
[]string{
|
||||||
strconv.FormatUint(user.GetId(), 10),
|
strconv.FormatUint(user.GetId(), util.Base10),
|
||||||
user.GetDisplayName(),
|
user.GetDisplayName(),
|
||||||
user.GetName(),
|
user.GetName(),
|
||||||
user.GetEmail(),
|
user.GetEmail(),
|
||||||
user.GetCreatedAt().AsTime().Format("2006-01-02 15:04:05"),
|
user.GetCreatedAt().AsTime().Format(HeadscaleDateTimeFormat),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user