Add --output flags to pause and unpause as well

pull/9576/head
Priya Wadhwa 2020-10-28 13:16:17 -07:00
parent a2fcd8e37b
commit 39ab9ffc5b
5 changed files with 13 additions and 6 deletions

View File

@ -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]")
}

View File

@ -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]")
}

View File

@ -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

View File

@ -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)

View File

@ -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]")
}