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

fixed accidental folder deletion bug when using minikube delete --purge #19771

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we kind of did a mistake in the previous release not to think about this, the rightthing to do is,
in the delete --purge code. we need to Check What folders we are deleting...and if there is any folder other than minikube sub folders we should Warn the user if they wanna proceed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you left a comment on issue #19769 that describes an alternative solution:

alternatvely we should enforce users to set their minikube home folder to something that is called .minikube, so in the purge we only delete .minikube folder

I replied to the comment detailing why I think this alternative is the best approach and that adding a prompt while keeping the current MiniPath() behavior will actually be not aid in the overall goal of getting users to use a directory named ".minikube" as the config directory.

I'm a little confused about what solution to pursue of the two options presented in the comment. If you want a yes/no prompt that verifies whether the user wants to delete a directory when it's not named ".minikube" then I can rewrite the code. Just let me know, because I'm a little unclear on what direction I should go in.

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
2 changes: 1 addition & 1 deletion pkg/minikube/localpath/localpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestMiniPath(t *testing.T) {
env, expectedPath string
}{
{"/tmp/.minikube", "/tmp/.minikube"},
{"/tmp", "/tmp"},
{"/tmp", "/tmp/.minikube"},
{"", filepath.Join(homedir.HomeDir(), ".minikube")},
}
for _, tc := range testCases {
Expand Down