use user cache directory for remote helmfiles

Signed-off-by: Quan TRAN <account@itscaro.me>
This commit is contained in:
Quan TRAN
2022-02-12 17:52:52 +09:00
committed by Yusuke Kuoka
parent 242e601898
commit baafe702b2
2 changed files with 3 additions and 19 deletions
+2 -12
View File
@@ -15,20 +15,13 @@ import (
"gopkg.in/yaml.v2"
)
const defaultCacheDir = "helmfile"
func CacheDir() string {
dir, err := os.UserCacheDir()
if err != nil {
// fall back to relative path with hidden directory
return relativeCacheDir()
return ".helmfile"
}
return filepath.Join(dir, defaultCacheDir)
}
// TODO remove this function when rework on caching of remote helmfiles
func relativeCacheDir() string {
return fmt.Sprintf(".%s", defaultCacheDir)
return filepath.Join(dir, "helmfile")
}
type Remote struct {
@@ -293,9 +286,6 @@ func NewRemote(logger *zap.SugaredLogger, homeDir string, readFile func(string)
if remote.Home == "" {
// Use for remote charts
remote.Home = CacheDir()
} else {
// Use for remote helmfiles, this case Home is relative to the processing file
remote.Home = filepath.Join(remote.Home, relativeCacheDir())
}
return remote