diff --git a/cmd/minikube/cmd/config/profile.go b/cmd/minikube/cmd/config/profile.go index 67203ebdbf69..778402408970 100644 --- a/cmd/minikube/cmd/config/profile.go +++ b/cmd/minikube/cmd/config/profile.go @@ -23,7 +23,6 @@ import ( "github.com/spf13/viper" pkgConfig "k8s.io/minikube/pkg/minikube/config" pkg_config "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" "k8s.io/minikube/pkg/minikube/out" @@ -87,7 +86,7 @@ var ProfileCmd = &cobra.Command{ out.SuccessT("Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.", out.V{"profile_name": profile}) out.SuccessT("To connect to this cluster, use: kubectl --context={{.profile_name}}", out.V{"profile_name": profile}) } else { - err := kubeconfig.SetCurrentContext(profile, constants.KubeconfigPath) + err := kubeconfig.SetCurrentContext(profile, kubeconfig.PathFromEnv()) if err != nil { out.ErrT(out.Sad, `Error while setting kubectl current context : {{.error}}`, out.V{"error": err}) } diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index f9f90b791709..5bf8894f6702 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -26,7 +26,6 @@ import ( "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/cluster" pkg_config "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" "k8s.io/minikube/pkg/minikube/machine" @@ -82,7 +81,7 @@ func runStop(cmd *cobra.Command, args []string) { out.T(out.WarningType, "Unable to kill mount process: {{.error}}", out.V{"error": err}) } - err = kubeconfig.UnsetCurrentContext(profile, constants.KubeconfigPath) + err = kubeconfig.UnsetCurrentContext(profile, kubeconfig.PathFromEnv()) if err != nil { exit.WithError("update config", err) } diff --git a/cmd/minikube/cmd/update-context.go b/cmd/minikube/cmd/update-context.go index e7e4a9aea6f1..5a5dac761bbb 100644 --- a/cmd/minikube/cmd/update-context.go +++ b/cmd/minikube/cmd/update-context.go @@ -17,13 +17,10 @@ limitations under the License. package cmd import ( - "os" - "github.com/spf13/cobra" "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" "k8s.io/minikube/pkg/minikube/machine" @@ -47,13 +44,7 @@ var updateContextCmd = &cobra.Command{ if err != nil { exit.WithError("Error host driver ip status", err) } - var updated bool - kubeConfigPath := os.Getenv("KUBECONFIG") - if kubeConfigPath == "" { - updated, err = kubeconfig.UpdateIP(ip, machineName, constants.KubeconfigPath) - } else { - updated, err = kubeconfig.UpdateIP(ip, machineName, kubeConfigPath) - } + updated, err := kubeconfig.UpdateIP(ip, machineName, kubeconfig.PathFromEnv()) if err != nil { exit.WithError("update config", err) }