Skip to content

Commit

Permalink
add docker-env and podman-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 23, 2021
1 parent f29366a commit 2779ec0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 2 additions & 3 deletions cmd/minikube/cmd/docker-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ 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)
Expand All @@ -265,8 +266,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
15 changes: 15 additions & 0 deletions cmd/minikube/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/kverify"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/kubeconfig"
Expand Down Expand Up @@ -136,6 +137,8 @@ type Status struct {
Kubeconfig string
Worker bool
TimeToStop string
DockerEnv string `json:",omitempty"`
PodManEnv string `json:",omitempty"`
}

// ClusterState holds a cluster state representation
Expand Down Expand Up @@ -183,6 +186,12 @@ kubelet: {{.Kubelet}}
apiserver: {{.APIServer}}
kubeconfig: {{.Kubeconfig}}
timeToStop: {{.TimeToStop}}
{{- if .DockerEnv }}
docker-env: {{.DockerEnv}}
{{- end }}
{{- if .PodManEnv }}
podman-env: {{.PodManEnv}}
{{- end }}
`
workerStatusFormat = `{{.Name}}
Expand Down Expand Up @@ -374,6 +383,12 @@ 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 os.Getenv(constants.MinikubeActiveDockerdEnv) != "" {
st.DockerEnv = "in-use"
}
if os.Getenv(constants.MinikubeActivePodmanEnv) != "" {
st.PodManEnv = "in-use"
}
// Early exit for worker nodes
if !controlPlane {
return st, nil
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: {{.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")
Expand Down

0 comments on commit 2779ec0

Please sign in to comment.