mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-27 12:05:26 +00:00
Better table in preauthkeys
This commit is contained in:
parent
350f7da55d
commit
f194b41435
@ -3,10 +3,12 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hako/durafmt"
|
"github.com/hako/durafmt"
|
||||||
|
"github.com/pterm/pterm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +56,8 @@ var listPreAuthKeys = &cobra.Command{
|
|||||||
fmt.Printf("Error getting the list of keys: %s\n", err)
|
fmt.Printf("Error getting the list of keys: %s\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d := pterm.TableData{{"ID", "Key", "Reusable", "Ephemeral", "Expiration", "Created"}}
|
||||||
for _, k := range *keys {
|
for _, k := range *keys {
|
||||||
expiration := "-"
|
expiration := "-"
|
||||||
if k.Expiration != nil {
|
if k.Expiration != nil {
|
||||||
@ -67,16 +71,17 @@ var listPreAuthKeys = &cobra.Command{
|
|||||||
reusable = fmt.Sprintf("%v", k.Reusable)
|
reusable = fmt.Sprintf("%v", k.Reusable)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(
|
d = append(d, []string{
|
||||||
"key: %s, namespace: %s, reusable: %s, ephemeral: %v, expiration: %s, created_at: %s\n",
|
strconv.FormatUint(k.ID, 10),
|
||||||
k.Key,
|
k.Key,
|
||||||
k.Namespace.Name,
|
|
||||||
reusable,
|
reusable,
|
||||||
k.Ephemeral,
|
strconv.FormatBool(k.Ephemeral),
|
||||||
expiration,
|
expiration,
|
||||||
k.CreatedAt.Format("2006-01-02 15:04:05"),
|
k.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
)
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
pterm.DefaultTable.WithHasHeader().WithData(d).Render()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user