use user cache directory for remote helmfiles
Signed-off-by: Quan TRAN <account@itscaro.me>
This commit is contained in:
parent
242e601898
commit
baafe702b2
|
|
@ -998,12 +998,7 @@ func (a *App) visitStatesWithSelectorsAndRemoteSupport(fileOrDir string, converg
|
|||
opts.Environment.OverrideValues = envvals
|
||||
}
|
||||
|
||||
dir, err := a.getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.remote = remote.NewRemote(a.Logger, dir, a.readFile, a.directoryExistsAt, a.fileExistsAt)
|
||||
a.remote = remote.NewRemote(a.Logger, "", a.readFile, a.directoryExistsAt, a.fileExistsAt)
|
||||
|
||||
f := converge
|
||||
if opts.Filter {
|
||||
|
|
@ -2098,7 +2093,6 @@ func (a *App) ShowCacheDir(c ListConfigProvider) error {
|
|||
|
||||
func (a *App) CleanCacheDir(c ListConfigProvider) error {
|
||||
if !directoryExistsAt(remote.CacheDir()) {
|
||||
fmt.Printf("Nothing to remove in cache directory: %s\n", remote.CacheDir())
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("Cleaning up cache directory: %s\n", remote.CacheDir())
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue