diff --git a/cmd/minikube/cmd/pause.go b/cmd/minikube/cmd/pause.go index 7cfa359f80..55e44147b2 100644 --- a/cmd/minikube/cmd/pause.go +++ b/cmd/minikube/cmd/pause.go @@ -50,6 +50,7 @@ var pauseCmd = &cobra.Command{ } func runPause(cmd *cobra.Command, args []string) { + out.SetJSON(outputFormat == "json") co := mustload.Running(ClusterFlagValue()) register.SetEventLogPath(localpath.EventLog(ClusterFlagValue())) register.Reg.SetStep(register.Pausing) @@ -105,4 +106,5 @@ func runPause(cmd *cobra.Command, args []string) { func init() { pauseCmd.Flags().StringSliceVarP(&namespaces, "--namespaces", "n", constants.DefaultNamespaces, "namespaces to pause") pauseCmd.Flags().BoolVarP(&allNamespaces, "all-namespaces", "A", false, "If set, pause all namespaces") + pauseCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]") } diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index a773eec844..7caad3890f 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -128,7 +128,7 @@ func platform() string { func runStart(cmd *cobra.Command, args []string) { register.SetEventLogPath(localpath.EventLog(ClusterFlagValue())) - out.SetJSON(viper.GetString(outputFormat) == "json") + out.SetJSON(outputFormat == "json") displayVersion(version.GetVersion()) // No need to do the update check if no one is going to see it @@ -1074,7 +1074,7 @@ func validateFlags(cmd *cobra.Command, drvName string) { } } - if s := viper.GetString(outputFormat); s != "text" && s != "json" { + if outputFormat != "text" && outputFormat != "json" { exit.Message(reason.Usage, "Sorry, please set the --output flag to one of the following valid options: [text,json]") } diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index dce9ad68fd..dc80fe263d 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -106,10 +106,13 @@ const ( deleteOnFailure = "delete-on-failure" forceSystemd = "force-systemd" kicBaseImage = "base-image" - outputFormat = "output" ports = "ports" ) +var ( + outputFormat string +) + // initMinikubeFlags includes commandline flags for minikube. func initMinikubeFlags() { viper.SetEnvPrefix(minikubeEnvPrefix) @@ -147,7 +150,7 @@ func initMinikubeFlags() { startCmd.Flags().Bool(preload, true, "If set, download tarball of preloaded images if available to improve start time. Defaults to true.") startCmd.Flags().Bool(deleteOnFailure, false, "If set, delete the current cluster if start fails and try again. Defaults to false.") startCmd.Flags().Bool(forceSystemd, false, "If set, force the container runtime to use sytemd as cgroup manager. Currently available for docker and crio. Defaults to false.") - startCmd.Flags().StringP(outputFormat, "o", "text", "Format to print stdout in. Options include: [text,json]") + startCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]") } // initKubernetesFlags inits the commandline flags for Kubernetes related options diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index 145dfb2832..d2a4f02287 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -55,7 +55,7 @@ var stopCmd = &cobra.Command{ func init() { stopCmd.Flags().BoolVar(&stopAll, "all", false, "Set flag to stop all profiles (clusters)") stopCmd.Flags().BoolVar(&keepActive, "keep-context-active", false, "keep the kube-context active after cluster is stopped. Defaults to false.") - stopCmd.Flags().StringP(outputFormat, "o", "text", "Format to print stdout in. Options include: [text,json]") + stopCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]") if err := viper.GetViper().BindPFlags(stopCmd.Flags()); err != nil { exit.Error(reason.InternalFlagsBind, "unable to bind flags", err) @@ -64,7 +64,7 @@ func init() { // runStop handles the executes the flow of "minikube stop" func runStop(cmd *cobra.Command, args []string) { - out.SetJSON(viper.GetString(outputFormat) == "json") + out.SetJSON(outputFormat == "json") register.SetEventLogPath(localpath.EventLog(ClusterFlagValue())) register.Reg.SetStep(register.Stopping) diff --git a/cmd/minikube/cmd/unpause.go b/cmd/minikube/cmd/unpause.go index 7d0b53de17..69aa1329bd 100644 --- a/cmd/minikube/cmd/unpause.go +++ b/cmd/minikube/cmd/unpause.go @@ -46,6 +46,7 @@ var unpauseCmd = &cobra.Command{ register.SetEventLogPath(localpath.EventLog(cname)) co := mustload.Running(cname) + out.SetJSON(outputFormat == "json") register.Reg.SetStep(register.Unpausing) klog.Infof("namespaces: %v keys: %v", namespaces, viper.AllSettings()) @@ -106,4 +107,5 @@ var unpauseCmd = &cobra.Command{ func init() { unpauseCmd.Flags().StringSliceVarP(&namespaces, "--namespaces", "n", constants.DefaultNamespaces, "namespaces to unpause") unpauseCmd.Flags().BoolVarP(&allNamespaces, "all-namespaces", "A", false, "If set, unpause all namespaces") + unpauseCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]") }