Skip to content
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
4 changes: 2 additions & 2 deletions pkg/minikube/kubeconfig/kubeconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func TestUpdateIP(t *testing.T) {
},
}

t.Setenv(localpath.MinikubeHome, "/home/la-croix/.minikube")
t.Setenv(localpath.MinikubeHome, "/home/la-croix")

for _, test := range tests {
test := test
Expand Down Expand Up @@ -492,7 +492,7 @@ func TestUpdateIP(t *testing.T) {
}

func TestMissingContext(t *testing.T) {
t.Setenv(localpath.MinikubeHome, "/home/la-croix/.minikube")
t.Setenv(localpath.MinikubeHome, "/home/la-croix")
configFilename := tempFile(t, kubeConfigMissingContext)
defer os.Remove(configFilename)
if _, err := UpdateEndpoint("minikube", "192.168.10.100", 8080, configFilename, nil); err != nil {
Expand Down
7 changes: 1 addition & 6 deletions pkg/minikube/localpath/localpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ func MiniPath() string {
if filepath.Base(minikubeHomeEnv) == ".minikube" {
return minikubeHomeEnv
}

legacyMinikubeHome := filepath.Join(minikubeHomeEnv, ".minikube")
if _, err := os.Stat(legacyMinikubeHome); !os.IsNotExist(err) {
return legacyMinikubeHome
}
return filepath.Clean(minikubeHomeEnv)
return filepath.Join(minikubeHomeEnv, ".minikube")
}

// MakeMiniPath is a utility to calculate a relative path to our directory.
Expand Down
13 changes: 7 additions & 6 deletions pkg/minikube/localpath/localpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,19 @@ func TestHasWindowsDriveLetter(t *testing.T) {

func TestMiniPath(t *testing.T) {
var testCases = []struct {
env, expectedPath string
env, basePath string
}{
{"/tmp/.minikube", "/tmp/.minikube"},
{"/tmp", "/tmp"},
{"", filepath.Join(homedir.HomeDir(), ".minikube")},
{"/tmp/.minikube", "/tmp/"},
{"/tmp/", "/tmp"},
{"", homedir.HomeDir()},
}
for _, tc := range testCases {
t.Run(tc.env, func(t *testing.T) {
expectedPath := filepath.Join(tc.basePath, ".minikube")
t.Setenv(MinikubeHome, tc.env)
path := MiniPath()
if path != tc.expectedPath {
t.Errorf("MiniPath expected to return '%s', but got '%s'", tc.expectedPath, path)
if path != expectedPath {
t.Errorf("MiniPath expected to return '%s', but got '%s'", expectedPath, path)
}
})
}
Expand Down