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 |
|----------------------|------------------|--------------------------------------------------------------------------------------------------------------|
| `--no-dashboard` | `false` | Don't host the dashboard (not applicable at the moment) |
| `--dashboard-port` | `8899` | local port that dashboard will be forwarded to |
| `--no-gui` | `false` | Don't host the web interface (not applicable at the moment) |
| `--gui-port` | `8899` | local port that web interface will be forwarded to |
| `--namespace` | | use namespace different than the one found in kubeconfig |
| `--kubeconfig` | | Path to custom kubeconfig file |

View File

@@ -1,7 +1,7 @@
package cmd
import (
"errors"
"fmt"
"github.com/spf13/cobra"
)
@@ -10,7 +10,8 @@ var fetchCmd = &cobra.Command{
Use: "fetch",
Short: "Download recorded traffic",
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() {
rootCmd.AddCommand(tapCmd)
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().Uint16VarP(&config.Configuration.DashboardPort, "dashboard-port", "p", 8899, "Provide a custom port for the dashboard webserver")
// tapCmd.Flags().BoolVarP(&config.Configuration.Quiet, "quiet", "q", false, "No stdout output")
tapCmd.Flags().BoolVarP(&config.Configuration.NoGUI, "no-gui", "", false, "Do not open web interface")
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().BoolVarP(&config.Configuration.AllNamespaces, "all-namespaces", "A", false, "Select all namespaces")
tapCmd.Flags().StringVarP(&config.Configuration.KubeConfigPath, "kubeconfig", "k", "", "Path to kubeconfig file")

View File

@@ -1,7 +1,7 @@
package cmd
import (
"errors"
"fmt"
"github.com/spf13/cobra"
)
@@ -10,7 +10,8 @@ var viewCmd = &cobra.Command{
Use: "view",
Short: "Open GUI in browser",
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
type Options struct {
Quiet bool
NoDashboard bool
DashboardPort uint16
NoGUI bool
GuiPort uint16
Namespace string
AllNamespaces bool
KubeConfigPath string
MizuImage string
MizuPodPort uint16

View File

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