Skip to content

Commit

Permalink
add docker-env to minikube status
Browse files Browse the repository at this point in the history
Signed-off-by: Tharun <[email protected]>
  • Loading branch information
tharun208 committed Mar 19, 2021
1 parent 63a8f28 commit ef55afb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cmd/minikube/cmd/docker-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ var dockerEnvCmd = &cobra.Command{
sh := shell.EnvConfig{
Shell: shl,
}

cname := ClusterFlagValue()
co := mustload.Running(cname)
if dockerUnset {
if err := dockerUnsetScript(DockerEnvConfig{EnvConfig: sh}, os.Stdout); err != nil {
exit.Error(reason.InternalEnvScript, "Error generating unset output", err)
}
co.Config.DockerEnvInUse = false
return
}

Expand All @@ -265,8 +267,6 @@ var dockerEnvCmd = &cobra.Command{
exit.SetShell(true)
}

cname := ClusterFlagValue()
co := mustload.Running(cname)
driverName := co.CP.Host.DriverName

if driverName == driver.None {
Expand Down Expand Up @@ -355,6 +355,7 @@ var dockerEnvCmd = &cobra.Command{
exit.Error(reason.IfSSHClient, "Error with ssh-add", err)
}
}
co.Config.DockerEnvInUse = true
},
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type Status struct {
Kubeconfig string
Worker bool
TimeToStop string
DockerEnv string
}

// ClusterState holds a cluster state representation
Expand Down Expand Up @@ -183,6 +184,9 @@ kubelet: {{.Kubelet}}
apiserver: {{.APIServer}}
kubeconfig: {{.Kubeconfig}}
timeToStop: {{.TimeToStop}}
{{- if .DockerEnv }}
docker-env: in-use
{{- end }}
`
workerStatusFormat = `{{.Name}}
Expand Down Expand Up @@ -374,6 +378,9 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St
initiationTime := time.Unix(cc.ScheduledStop.InitiationTime, 0)
st.TimeToStop = time.Until(initiationTime.Add(cc.ScheduledStop.Duration)).String()
}
if cc.DockerEnvInUse {
st.DockerEnv = "in-use"
}
// Early exit for worker nodes
if !controlPlane {
return st, nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/minikube/cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func TestStatusText(t *testing.T) {
}{
{
name: "ok",
state: &Status{Name: "minikube", Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m"},
want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Running\napiserver: Running\nkubeconfig: Configured\ntimeToStop: 10m\n\n",
state: &Status{Name: "minikube", Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m", DockerEnv: "in-use"},
want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Running\napiserver: Running\nkubeconfig: Configured\ntimeToStop: 10m\ndocker-env: in-use\n\n",
},
{
name: "paused",
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ClusterConfig struct {
ListenAddress string // Only used by the docker and podman driver
Network string // only used by docker driver
MultiNodeRequested bool
DockerEnvInUse bool
}

// KubernetesConfig contains the parameters used to configure the VM Kubernetes.
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\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}}\ntimeToStop: {{.TimeToStop}}\n{{- if .DockerEnv }}\ndocker-env: in-use\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")
Expand Down

0 comments on commit ef55afb

Please sign in to comment.