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

profile list --output json handle empty config folder #16900

Merged
Merged
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: 4 additions & 0 deletions pkg/minikube/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func profileDirs(miniHome ...string) (dirs []string, err error) {
}
pRootDir := filepath.Join(miniPath, "profiles")
items, err := os.ReadDir(pRootDir)
if os.IsNotExist(err) {
return dirs, &ErrNotExist{fmt.Sprintf("profiles dir %s does not exist", pRootDir)}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the best way to handle this is to return here empty list of directories and no error since this is an expected condition before any profile was created, or if a user deleted the profiles directory.

However if we report an error, we should do the check correctly - it seems that you are adding here a wrong check:

if err == os.IsNotExist(err)

And you fix it in the next commit? Did you forget to squash the next commit into this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I squashed the next commit. The comparison is good now.

About the error return; I am hoping that that error case is handled specially as it is a ERRNOTEXIST and I am leaving that handling to the caller.


for _, f := range items {
if f.IsDir() {
dirs = append(dirs, f.Name())
Expand Down