mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #35745 from rodcloutier/Support_Home_env_windows
Automatic merge from submit-queue Added support for HOME environment variable on Windows **What this PR does / why we need it**: On Windows the HOME environment variable should be taken in account when trying to find the home directory. Several tools already support the HOME environment variable, notably git-bash. It would be very convenient to have the kubernete tools (including minikube) to also support the environment variable. The current situation **Special notes for your reviewer**: **Release note**: ``` ```
This commit is contained in:
commit
63044c410e
@ -24,6 +24,13 @@ import (
|
||||
// HomeDir returns the home directory for the current user
|
||||
func HomeDir() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
|
||||
// First prefer the HOME environmental variable
|
||||
if home := os.Getenv("HOME"); len(home) > 0 {
|
||||
if _, err := os.Stat(home); err == nil {
|
||||
return home
|
||||
}
|
||||
}
|
||||
if homeDrive, homePath := os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"); len(homeDrive) > 0 && len(homePath) > 0 {
|
||||
homeDir := homeDrive + homePath
|
||||
if _, err := os.Stat(homeDir); err == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user