提交 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 {
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)
......
......@@ -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) {
......
......@@ -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")
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册