Skip to content

Commit

Permalink
Constants: Creates cache and bin directories as part of EnsureBaseDir…
Browse files Browse the repository at this point in the history
…ectoriesExist

As of now we only create `$HOME/.crc` directory as part of root init function and
other child directories are created on demand like cache is created when bundle is
download and extracted. Recently we observed that required child directory (bin) is not
exist when creating a symlink. It is easy to miss to check for well known crc clild
directory when writing code and assumed it should be always there to consume.

We have identified `$HOME/.crc`, `$HOME/.crc/bin` and `$HOME/.crc/cache` are needed
directories to `crc` to work so this commit create those as part of init function from
root.
  • Loading branch information
praveenkumar committed Apr 21, 2022
1 parent 81a5f33 commit 327bc49
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@ func GetHomeDir() string {
return homeDir
}

// EnsureBaseDirectoryExists create the ~/.crc directory if it is not present
// EnsureBaseDirectoriesExist creates ~/.crc, ~/.crc/bin and ~/.crc/cache directories if it is not present
func EnsureBaseDirectoriesExist() error {
return os.MkdirAll(CrcBaseDir, 0750)
baseDirectories := []string{CrcBaseDir, MachineCacheDir, crcBinDir}
for _, baseDir := range baseDirectories {
err := os.MkdirAll(baseDir, 0750)
if err != nil {
return err
}
}
return nil
}

func IsRelease() bool {
Expand Down

0 comments on commit 327bc49

Please sign in to comment.