From 8d1e4e2d26cb01c1bf3380f4d0bf71292dbdea60 Mon Sep 17 00:00:00 2001 From: Harkishen-Singh Date: Wed, 17 Jun 2020 23:54:00 +0530 Subject: [PATCH] adds support for unsetting of environment variables without the need of running container-machine Signed-off-by: Harkishen-Singh --- cmd/minikube/cmd/docker-env.go | 22 +++++++++++----------- cmd/minikube/cmd/podman-env.go | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/cmd/minikube/cmd/docker-env.go b/cmd/minikube/cmd/docker-env.go index d9bba7a31162..3899fb83487d 100644 --- a/cmd/minikube/cmd/docker-env.go +++ b/cmd/minikube/cmd/docker-env.go @@ -133,6 +133,17 @@ var dockerEnvCmd = &cobra.Command{ Short: "Configure environment to use minikube's Docker daemon", Long: `Sets up docker env variables; similar to '$(docker-machine env)'.`, Run: func(cmd *cobra.Command, args []string) { + sh := shell.EnvConfig{ + Shell: shell.ForceShell, + } + + if dockerUnset { + if err := dockerUnsetScript(DockerEnvConfig{EnvConfig: sh}, os.Stdout); err != nil { + exit.WithError("Error generating unset output", err) + } + return + } + cname := ClusterFlagValue() co := mustload.Running(cname) driverName := co.CP.Host.DriverName @@ -146,10 +157,6 @@ var dockerEnvCmd = &cobra.Command{ out.V{"runtime": co.Config.KubernetesConfig.ContainerRuntime}) } - sh := shell.EnvConfig{ - Shell: shell.ForceShell, - } - if ok := isDockerActive(co.CP.Runner); !ok { glog.Warningf("dockerd is not active will try to restart it...") mustRestartDocker(cname, co.CP.Runner) @@ -188,13 +195,6 @@ var dockerEnvCmd = &cobra.Command{ mustRestartDocker(cname, co.CP.Runner) } - if dockerUnset { - if err := dockerUnsetScript(ec, os.Stdout); err != nil { - exit.WithError("Error generating unset output", err) - } - return - } - if err := dockerSetScript(ec, os.Stdout); err != nil { exit.WithError("Error generating set output", err) } diff --git a/cmd/minikube/cmd/podman-env.go b/cmd/minikube/cmd/podman-env.go index 8bff0ce56fd7..9688918ad4fe 100644 --- a/cmd/minikube/cmd/podman-env.go +++ b/cmd/minikube/cmd/podman-env.go @@ -108,6 +108,17 @@ var podmanEnvCmd = &cobra.Command{ Short: "Configure environment to use minikube's Podman service", Long: `Sets up podman env variables; similar to '$(podman-machine env)'.`, Run: func(cmd *cobra.Command, args []string) { + sh := shell.EnvConfig{ + Shell: shell.ForceShell, + } + + if podmanUnset { + if err := podmanUnsetScript(PodmanEnvConfig{EnvConfig: sh}, os.Stdout); err != nil { + exit.WithError("Error generating unset output", err) + } + return + } + cname := ClusterFlagValue() co := mustload.Running(cname) driverName := co.CP.Host.DriverName @@ -125,9 +136,6 @@ var podmanEnvCmd = &cobra.Command{ exit.WithError("Error getting ssh client", err) } - sh := shell.EnvConfig{ - Shell: shell.ForceShell, - } ec := PodmanEnvConfig{ EnvConfig: sh, profile: cname, @@ -142,13 +150,6 @@ var podmanEnvCmd = &cobra.Command{ } } - if podmanUnset { - if err := podmanUnsetScript(ec, os.Stdout); err != nil { - exit.WithError("Error generating unset output", err) - } - return - } - if err := podmanSetScript(ec, os.Stdout); err != nil { exit.WithError("Error generating set output", err) }