Skip to content

Commit 2779ec0

Browse files
committed
add docker-env and podman-env to minikube status
Signed-off-by: Tharun <[email protected]>
1 parent f29366a commit 2779ec0

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

cmd/minikube/cmd/docker-env.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ var dockerEnvCmd = &cobra.Command{
252252
sh := shell.EnvConfig{
253253
Shell: shl,
254254
}
255-
255+
cname := ClusterFlagValue()
256+
co := mustload.Running(cname)
256257
if dockerUnset {
257258
if err := dockerUnsetScript(DockerEnvConfig{EnvConfig: sh}, os.Stdout); err != nil {
258259
exit.Error(reason.InternalEnvScript, "Error generating unset output", err)
@@ -265,8 +266,6 @@ var dockerEnvCmd = &cobra.Command{
265266
exit.SetShell(true)
266267
}
267268

268-
cname := ClusterFlagValue()
269-
co := mustload.Running(cname)
270269
driverName := co.CP.Host.DriverName
271270

272271
if driverName == driver.None {

cmd/minikube/cmd/status.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/kverify"
3838
"k8s.io/minikube/pkg/minikube/cluster"
3939
"k8s.io/minikube/pkg/minikube/config"
40+
"k8s.io/minikube/pkg/minikube/constants"
4041
"k8s.io/minikube/pkg/minikube/driver"
4142
"k8s.io/minikube/pkg/minikube/exit"
4243
"k8s.io/minikube/pkg/minikube/kubeconfig"
@@ -136,6 +137,8 @@ type Status struct {
136137
Kubeconfig string
137138
Worker bool
138139
TimeToStop string
140+
DockerEnv string `json:",omitempty"`
141+
PodManEnv string `json:",omitempty"`
139142
}
140143

141144
// ClusterState holds a cluster state representation
@@ -183,6 +186,12 @@ kubelet: {{.Kubelet}}
183186
apiserver: {{.APIServer}}
184187
kubeconfig: {{.Kubeconfig}}
185188
timeToStop: {{.TimeToStop}}
189+
{{- if .DockerEnv }}
190+
docker-env: {{.DockerEnv}}
191+
{{- end }}
192+
{{- if .PodManEnv }}
193+
podman-env: {{.PodManEnv}}
194+
{{- end }}
186195
187196
`
188197
workerStatusFormat = `{{.Name}}
@@ -374,6 +383,12 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St
374383
initiationTime := time.Unix(cc.ScheduledStop.InitiationTime, 0)
375384
st.TimeToStop = time.Until(initiationTime.Add(cc.ScheduledStop.Duration)).String()
376385
}
386+
if os.Getenv(constants.MinikubeActiveDockerdEnv) != "" {
387+
st.DockerEnv = "in-use"
388+
}
389+
if os.Getenv(constants.MinikubeActivePodmanEnv) != "" {
390+
st.PodManEnv = "in-use"
391+
}
377392
// Early exit for worker nodes
378393
if !controlPlane {
379394
return st, nil

site/content/en/docs/commands/status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ minikube status [flags]
2323

2424
```
2525
-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/
26-
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")
26+
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")
2727
-l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes")
2828
-n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes.
2929
-o, --output string minikube status --output OUTPUT. json, text (default "text")

0 commit comments

Comments
 (0)