diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 710990297ba04ed50a4eb9dbd868eea8e9d2bc8f..dd651e15925f52162a6d824da8c9d75a8696c4a5 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -136,7 +136,7 @@ type Status struct { APIServer string Kubeconfig string Worker bool - TimeToStop string + TimeToStop string `json:",omitempty"` DockerEnv string `json:",omitempty"` PodManEnv string `json:",omitempty"` } @@ -146,7 +146,7 @@ type ClusterState struct { BaseState BinaryVersion string - TimeToStop string + TimeToStop string `json:",omitempty"` Components map[string]BaseState Nodes []NodeState } @@ -185,7 +185,9 @@ host: {{.Host}} kubelet: {{.Kubelet}} apiserver: {{.APIServer}} kubeconfig: {{.Kubeconfig}} +{{- if .TimeToStop }} timeToStop: {{.TimeToStop}} +{{- end }} {{- if .DockerEnv }} docker-env: {{.DockerEnv}} {{- end }} @@ -319,7 +321,6 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St Kubelet: Nonexistent, Kubeconfig: Nonexistent, Worker: !controlPlane, - TimeToStop: Nonexistent, } hs, err := machine.Status(api, name) diff --git a/cmd/minikube/cmd/status_test.go b/cmd/minikube/cmd/status_test.go index aa9f905c22af94669afef9ac90de563bdebc9494..bd794cbe32d0d2af31b8775d823e6950319547de 100644 --- a/cmd/minikube/cmd/status_test.go +++ b/cmd/minikube/cmd/status_test.go @@ -56,13 +56,13 @@ func TestStatusText(t *testing.T) { }, { name: "paused", - state: &Status{Name: "minikube", Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent}, - want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Stopped\napiserver: Paused\nkubeconfig: Configured\ntimeToStop: Nonexistent\n\n", + state: &Status{Name: "minikube", Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured}, + want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Stopped\napiserver: Paused\nkubeconfig: Configured\n\n", }, { name: "down", - state: &Status{Name: "minikube", Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent}, - want: "minikube\ntype: Control Plane\nhost: Stopped\nkubelet: Stopped\napiserver: Stopped\nkubeconfig: Misconfigured\ntimeToStop: Nonexistent\n\n\nWARNING: Your kubectl is pointing to stale minikube-vm.\nTo fix the kubectl context, run `minikube update-context`\n", + state: &Status{Name: "minikube", Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured}, + want: "minikube\ntype: Control Plane\nhost: Stopped\nkubelet: Stopped\napiserver: Stopped\nkubeconfig: Misconfigured\n\n\nWARNING: Your kubectl is pointing to stale minikube-vm.\nTo fix the kubectl context, run `minikube update-context`\n", }, } for _, tc := range tests { @@ -87,8 +87,8 @@ func TestStatusJSON(t *testing.T) { state *Status }{ {"ok", &Status{Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m"}}, - {"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent}}, - {"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent}}, + {"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured}}, + {"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured}}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { diff --git a/site/content/en/docs/commands/status.md b/site/content/en/docs/commands/status.md index 992691f07469ac31b66ac8f9aa61d28234bc02e4..109948ab56145b6f1d32903c1e6a1416c52f461c 100644 --- a/site/content/en/docs/commands/status.md +++ b/site/content/en/docs/commands/status.md @@ -23,7 +23,7 @@ minikube status [flags] ``` -f, --format string Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ - For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\ntimeToStop: {{.TimeToStop}}\n{{- if .DockerEnv }}\ndocker-env: {{.DockerEnv}}\n{{- end }}\n{{- if .PodManEnv }}\npodman-env: {{.PodManEnv}}\n{{- end }}\n\n") + For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\n{{- if .TimeToStop }}\ntimeToStop: {{.TimeToStop}}\n{{- end }}\n{{- if .DockerEnv }}\ndocker-env: {{.DockerEnv}}\n{{- end }}\n{{- if .PodManEnv }}\npodman-env: {{.PodManEnv}}\n{{- end }}\n\n") -l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes") -n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes. -o, --output string minikube status --output OUTPUT. json, text (default "text") diff --git a/test/integration/scheduled_stop_test.go b/test/integration/scheduled_stop_test.go index f10c4e2d6bf44a82fc670dc562f8323717be8f75..bfe05198a87846061df0e1a6f5ee57b5897ddb8a 100644 --- a/test/integration/scheduled_stop_test.go +++ b/test/integration/scheduled_stop_test.go @@ -69,8 +69,6 @@ func TestScheduledStopWindows(t *testing.T) { time.Sleep(5 * time.Second) // make sure minikube status is "Stopped" ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String()) - // make sure minikube timtostop is "Nonexistent" - ensureMinikubeStatus(ctx, t, profile, "TimeToStop", "Nonexistent") } func TestScheduledStopUnix(t *testing.T) { @@ -115,8 +113,6 @@ func TestScheduledStopUnix(t *testing.T) { // make sure minikube status is "Stopped" ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String()) - // make sure minikube timtostop is "Nonexistent" - ensureMinikubeStatus(ctx, t, profile, "TimeToStop", "Nonexistent") } func startMinikube(ctx context.Context, t *testing.T, profile string) {