mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
admin list frontends (#129)
This commit is contained in:
parent
d5d2497955
commit
9ab7eeebf3
62
cmd/zrok/admin_list_frontends.go
Normal file
62
cmd/zrok/admin_list_frontends.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/admin"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
adminListCmd.AddCommand(newAdminListFrontendsCommand().cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
type adminListFrontendsCommand struct {
|
||||||
|
cmd *cobra.Command
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAdminListFrontendsCommand() *adminListFrontendsCommand {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "frontends",
|
||||||
|
Aliases: []string{"fes"},
|
||||||
|
Short: "List global public frontends",
|
||||||
|
Args: cobra.ExactArgs(0),
|
||||||
|
}
|
||||||
|
command := &adminListFrontendsCommand{cmd: cmd}
|
||||||
|
cmd.Run = command.run
|
||||||
|
return command
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmd *adminListFrontendsCommand) run(_ *cobra.Command, args []string) {
|
||||||
|
zrok, err := zrokdir.ZrokClient(apiEndpoint)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := admin.NewListFrontendsParams()
|
||||||
|
resp, err := zrok.Admin.ListFrontends(req, mustGetAdminAuth())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println()
|
||||||
|
t := table.NewWriter()
|
||||||
|
t.SetOutputMirror(os.Stdout)
|
||||||
|
t.SetStyle(table.StyleColoredBright)
|
||||||
|
t.AppendHeader(table.Row{"Token", "zId", "Url Template", "Public Name", "Created At", "Updated At"})
|
||||||
|
for _, pfe := range resp.Payload {
|
||||||
|
t.AppendRow(table.Row{
|
||||||
|
pfe.Token,
|
||||||
|
pfe.ZID,
|
||||||
|
pfe.URLTemplate,
|
||||||
|
pfe.PublicName,
|
||||||
|
time.UnixMilli(pfe.CreatedAt),
|
||||||
|
time.UnixMilli(pfe.UpdatedAt),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
t.Render()
|
||||||
|
fmt.Println()
|
||||||
|
}
|
@ -18,6 +18,7 @@ func init() {
|
|||||||
rootCmd.AddCommand(accessCmd)
|
rootCmd.AddCommand(accessCmd)
|
||||||
adminCmd.AddCommand(adminCreateCmd)
|
adminCmd.AddCommand(adminCreateCmd)
|
||||||
adminCmd.AddCommand(adminDeleteCmd)
|
adminCmd.AddCommand(adminDeleteCmd)
|
||||||
|
adminCmd.AddCommand(adminListCmd)
|
||||||
rootCmd.AddCommand(adminCmd)
|
rootCmd.AddCommand(adminCmd)
|
||||||
rootCmd.AddCommand(shareCmd)
|
rootCmd.AddCommand(shareCmd)
|
||||||
rootCmd.AddCommand(testCmd)
|
rootCmd.AddCommand(testCmd)
|
||||||
@ -56,6 +57,11 @@ var adminDeleteCmd = &cobra.Command{
|
|||||||
Short: "Delete global resources",
|
Short: "Delete global resources",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var adminListCmd = &cobra.Command{
|
||||||
|
Use: "list",
|
||||||
|
Short: "List global resources",
|
||||||
|
}
|
||||||
|
|
||||||
var shareCmd = &cobra.Command{
|
var shareCmd = &cobra.Command{
|
||||||
Use: "share",
|
Use: "share",
|
||||||
Short: "Create backend access for services",
|
Short: "Create backend access for services",
|
||||||
|
Loading…
Reference in New Issue
Block a user