提交 628a4a83 编写于 作者: T Tharun

not mention timeToStop in status instead of showing NonExistent

Signed-off-by: NTharun <rajendrantharun@live.com>
上级 f567893c
...@@ -136,7 +136,7 @@ type Status struct { ...@@ -136,7 +136,7 @@ type Status struct {
APIServer string APIServer string
Kubeconfig string Kubeconfig string
Worker bool Worker bool
TimeToStop string TimeToStop string `json:",omitempty"`
DockerEnv string `json:",omitempty"` DockerEnv string `json:",omitempty"`
PodManEnv string `json:",omitempty"` PodManEnv string `json:",omitempty"`
} }
...@@ -146,7 +146,7 @@ type ClusterState struct { ...@@ -146,7 +146,7 @@ type ClusterState struct {
BaseState BaseState
BinaryVersion string BinaryVersion string
TimeToStop string TimeToStop string `json:",omitempty"`
Components map[string]BaseState Components map[string]BaseState
Nodes []NodeState Nodes []NodeState
} }
...@@ -185,7 +185,9 @@ host: {{.Host}} ...@@ -185,7 +185,9 @@ host: {{.Host}}
kubelet: {{.Kubelet}} kubelet: {{.Kubelet}}
apiserver: {{.APIServer}} apiserver: {{.APIServer}}
kubeconfig: {{.Kubeconfig}} kubeconfig: {{.Kubeconfig}}
{{- if .TimeToStop }}
timeToStop: {{.TimeToStop}} timeToStop: {{.TimeToStop}}
{{- end }}
{{- if .DockerEnv }} {{- if .DockerEnv }}
docker-env: {{.DockerEnv}} docker-env: {{.DockerEnv}}
{{- end }} {{- end }}
...@@ -319,7 +321,6 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St ...@@ -319,7 +321,6 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St
Kubelet: Nonexistent, Kubelet: Nonexistent,
Kubeconfig: Nonexistent, Kubeconfig: Nonexistent,
Worker: !controlPlane, Worker: !controlPlane,
TimeToStop: Nonexistent,
} }
hs, err := machine.Status(api, name) hs, err := machine.Status(api, name)
......
...@@ -56,13 +56,13 @@ func TestStatusText(t *testing.T) { ...@@ -56,13 +56,13 @@ func TestStatusText(t *testing.T) {
}, },
{ {
name: "paused", name: "paused",
state: &Status{Name: "minikube", Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent}, 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\ntimeToStop: Nonexistent\n\n", want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Stopped\napiserver: Paused\nkubeconfig: Configured\n\n",
}, },
{ {
name: "down", name: "down",
state: &Status{Name: "minikube", Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent}, 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\ntimeToStop: Nonexistent\n\n\nWARNING: Your kubectl is pointing to stale minikube-vm.\nTo fix the kubectl context, run `minikube update-context`\n", 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 { for _, tc := range tests {
...@@ -87,8 +87,8 @@ func TestStatusJSON(t *testing.T) { ...@@ -87,8 +87,8 @@ func TestStatusJSON(t *testing.T) {
state *Status state *Status
}{ }{
{"ok", &Status{Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m"}}, {"ok", &Status{Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m"}},
{"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent}}, {"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured}},
{"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent}}, {"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured}},
} }
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
......
...@@ -23,7 +23,7 @@ minikube status [flags] ...@@ -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/ -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") -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. -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") -o, --output string minikube status --output OUTPUT. json, text (default "text")
......
...@@ -69,8 +69,6 @@ func TestScheduledStopWindows(t *testing.T) { ...@@ -69,8 +69,6 @@ func TestScheduledStopWindows(t *testing.T) {
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
// make sure minikube status is "Stopped" // make sure minikube status is "Stopped"
ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String()) 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) { func TestScheduledStopUnix(t *testing.T) {
...@@ -115,8 +113,6 @@ func TestScheduledStopUnix(t *testing.T) { ...@@ -115,8 +113,6 @@ func TestScheduledStopUnix(t *testing.T) {
// make sure minikube status is "Stopped" // make sure minikube status is "Stopped"
ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String()) 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) { func startMinikube(ctx context.Context, t *testing.T, profile string) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册