Add JSON output to minikube stop

pull/9576/head
Priya Wadhwa 2020-10-28 11:30:11 -07:00
parent b8b432c8fe
commit 473120648f
3 changed files with 6 additions and 4 deletions

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(startOutput) == "json")
out.SetJSON(viper.GetString(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(startOutput); s != "text" && s != "json" {
if s := viper.GetString(outputFormat); s != "text" && s != "json" {
exit.Message(reason.Usage, "Sorry, please set the --output flag to one of the following valid options: [text,json]")
}

View File

@ -106,7 +106,7 @@ const (
deleteOnFailure = "delete-on-failure"
forceSystemd = "force-systemd"
kicBaseImage = "base-image"
startOutput = "output"
outputFormat = "output"
ports = "ports"
)
@ -147,7 +147,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(startOutput, "o", "text", "Format to print stdout in. Options include: [text,json]")
startCmd.Flags().StringP(outputFormat, "o", "text", "Format to print stdout in. Options include: [text,json]")
}
// initKubernetesFlags inits the commandline flags for Kubernetes related options

View File

@ -55,6 +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]")
if err := viper.GetViper().BindPFlags(stopCmd.Flags()); err != nil {
exit.Error(reason.InternalFlagsBind, "unable to bind flags", err)
@ -63,6 +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")
register.SetEventLogPath(localpath.EventLog(ClusterFlagValue()))
register.Reg.SetStep(register.Stopping)