CLI cleanup 2 (#34)

* Renamed dashboard -> GUI/web interface.

* Commented out --quiet, removed unused config variables.

* Quiter output when calling unimplemented subcommands.
This commit is contained in:
nimrod-up9
2021-05-06 18:30:01 +03:00
committed by GitHub
parent 6ceaa56474
commit 506e36fbdc
6 changed files with 16 additions and 16 deletions

View File

@@ -6,8 +6,8 @@
| flag | default | purpose | | flag | default | purpose |
|----------------------|------------------|--------------------------------------------------------------------------------------------------------------| |----------------------|------------------|--------------------------------------------------------------------------------------------------------------|
| `--no-dashboard` | `false` | Don't host the dashboard (not applicable at the moment) | | `--no-gui` | `false` | Don't host the web interface (not applicable at the moment) |
| `--dashboard-port` | `8899` | local port that dashboard will be forwarded to | | `--gui-port` | `8899` | local port that web interface will be forwarded to |
| `--namespace` | | use namespace different than the one found in kubeconfig | | `--namespace` | | use namespace different than the one found in kubeconfig |
| `--kubeconfig` | | Path to custom kubeconfig file | | `--kubeconfig` | | Path to custom kubeconfig file |

View File

@@ -1,7 +1,7 @@
package cmd package cmd
import ( import (
"errors" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -10,7 +10,8 @@ var fetchCmd = &cobra.Command{
Use: "fetch", Use: "fetch",
Short: "Download recorded traffic", Short: "Download recorded traffic",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return errors.New("Not implemented") fmt.Println("Not implemented")
return nil
}, },
} }

View File

@@ -31,9 +31,9 @@ var tapCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(tapCmd) rootCmd.AddCommand(tapCmd)
tapCmd.Flags().BoolVarP(&config.Configuration.Quiet, "quiet", "q", false, "No stdout output") // tapCmd.Flags().BoolVarP(&config.Configuration.Quiet, "quiet", "q", false, "No stdout output")
tapCmd.Flags().BoolVarP(&config.Configuration.NoDashboard, "no-dashboard", "", false, "Dont host a dashboard") tapCmd.Flags().BoolVarP(&config.Configuration.NoGUI, "no-gui", "", false, "Do not open web interface")
tapCmd.Flags().Uint16VarP(&config.Configuration.DashboardPort, "dashboard-port", "p", 8899, "Provide a custom port for the dashboard webserver") tapCmd.Flags().Uint16VarP(&config.Configuration.GuiPort, "gui-port", "p", 8899, "Provide a custom port for the web interface webserver")
tapCmd.Flags().StringVarP(&config.Configuration.Namespace, "namespace", "n", "", "Namespace selector") tapCmd.Flags().StringVarP(&config.Configuration.Namespace, "namespace", "n", "", "Namespace selector")
// tapCmd.Flags().BoolVarP(&config.Configuration.AllNamespaces, "all-namespaces", "A", false, "Select all namespaces") // tapCmd.Flags().BoolVarP(&config.Configuration.AllNamespaces, "all-namespaces", "A", false, "Select all namespaces")
tapCmd.Flags().StringVarP(&config.Configuration.KubeConfigPath, "kubeconfig", "k", "", "Path to kubeconfig file") tapCmd.Flags().StringVarP(&config.Configuration.KubeConfigPath, "kubeconfig", "k", "", "Path to kubeconfig file")

View File

@@ -1,7 +1,7 @@
package cmd package cmd
import ( import (
"errors" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -10,7 +10,8 @@ var viewCmd = &cobra.Command{
Use: "view", Use: "view",
Short: "Open GUI in browser", Short: "Open GUI in browser",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return errors.New("Not implemented") fmt.Println("Not implemented")
return nil
}, },
} }

View File

@@ -1,11 +1,9 @@
package config package config
type Options struct { type Options struct {
Quiet bool NoGUI bool
NoDashboard bool GuiPort uint16
DashboardPort uint16
Namespace string Namespace string
AllNamespaces bool
KubeConfigPath string KubeConfigPath string
MizuImage string MizuImage string
MizuPodPort uint16 MizuPodPort uint16

View File

@@ -75,9 +75,9 @@ func createPodAndPortForward(ctx context.Context, kubernetesProvider *kubernetes
if modifiedPod.Status.Phase == "Running" && !isPodReady { if modifiedPod.Status.Phase == "Running" && !isPodReady {
isPodReady = true isPodReady = true
var err error var err error
portForward, err = kubernetes.NewPortForward(kubernetesProvider, kubernetesProvider.Namespace, podName, config.Configuration.DashboardPort, config.Configuration.MizuPodPort, cancel) portForward, err = kubernetes.NewPortForward(kubernetesProvider, kubernetesProvider.Namespace, podName, config.Configuration.GuiPort, config.Configuration.MizuPodPort, cancel)
if !config.Configuration.NoDashboard { if !config.Configuration.NoGUI {
fmt.Printf("Dashboard is now available at http://localhost:%d\n", config.Configuration.DashboardPort) fmt.Printf("Web interface is now available at http://localhost:%d\n", config.Configuration.GuiPort)
} }
if err != nil { if err != nil {
fmt.Printf("error forwarding port to pod %s\n", err) fmt.Printf("error forwarding port to pod %s\n", err)