adds support for unsetting of environment variables without the need of running container-machine

Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
pull/8506/head
Harkishen-Singh 2020-06-17 23:54:00 +05:30
parent 804e772efd
commit 8d1e4e2d26
2 changed files with 22 additions and 21 deletions

View File

@ -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)
}

View File

@ -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)
}