Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for unsetting of env vars #8506

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cmd/minikube/cmd/docker-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
21 changes: 11 additions & 10 deletions cmd/minikube/cmd/podman-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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)
}
Expand Down