zrok agent console (#221)

This commit is contained in:
Michael Quigley 2024-10-04 15:45:19 -04:00
parent 6bcd5695ec
commit b0178a0619
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 32 additions and 1 deletions

31
cmd/zrok/agentConsole.go Normal file
View File

@ -0,0 +1,31 @@
package main
import (
"github.com/openziti/zrok/tui"
"github.com/spf13/cobra"
)
func init() {
agentCmd.AddCommand(newAgentConsoleCommand().cmd)
}
type agentConsoleCommand struct {
cmd *cobra.Command
}
func newAgentConsoleCommand() *agentConsoleCommand {
cmd := &cobra.Command{
Use: "console",
Short: "Open the Agent console",
Args: cobra.NoArgs,
}
command := &agentConsoleCommand{cmd}
cmd.Run = command.run
return command
}
func (cmd *agentConsoleCommand) run(_ *cobra.Command, _ []string) {
if err := openBrowser("http://localhost:8888"); err != nil {
tui.Error("unable to open agent console at 'http://localhost:8888'", err)
}
}

View File

@ -19,7 +19,7 @@ func newConsoleCommand() *consoleCommand {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "console", Use: "console",
Short: "Open the web console", Short: "Open the web console",
Args: cobra.ExactArgs(0), Args: cobra.NoArgs,
} }
command := &consoleCommand{cmd} command := &consoleCommand{cmd}
cmd.Run = command.run cmd.Run = command.run