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 | 		opts.Environment.OverrideValues = envvals | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	dir, err := a.getwd() | 	a.remote = remote.NewRemote(a.Logger, "", a.readFile, a.directoryExistsAt, a.fileExistsAt) | ||||||
| 	if err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	a.remote = remote.NewRemote(a.Logger, dir, a.readFile, a.directoryExistsAt, a.fileExistsAt) |  | ||||||
| 
 | 
 | ||||||
| 	f := converge | 	f := converge | ||||||
| 	if opts.Filter { | 	if opts.Filter { | ||||||
|  | @ -2098,7 +2093,6 @@ func (a *App) ShowCacheDir(c ListConfigProvider) error { | ||||||
| 
 | 
 | ||||||
| func (a *App) CleanCacheDir(c ListConfigProvider) error { | func (a *App) CleanCacheDir(c ListConfigProvider) error { | ||||||
| 	if !directoryExistsAt(remote.CacheDir()) { | 	if !directoryExistsAt(remote.CacheDir()) { | ||||||
| 		fmt.Printf("Nothing to remove in cache directory: %s\n", remote.CacheDir()) |  | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| 	fmt.Printf("Cleaning up cache directory: %s\n", remote.CacheDir()) | 	fmt.Printf("Cleaning up cache directory: %s\n", remote.CacheDir()) | ||||||
|  |  | ||||||
|  | @ -15,20 +15,13 @@ import ( | ||||||
| 	"gopkg.in/yaml.v2" | 	"gopkg.in/yaml.v2" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const defaultCacheDir = "helmfile" |  | ||||||
| 
 |  | ||||||
| func CacheDir() string { | func CacheDir() string { | ||||||
| 	dir, err := os.UserCacheDir() | 	dir, err := os.UserCacheDir() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		// fall back to relative path with hidden directory
 | 		// fall back to relative path with hidden directory
 | ||||||
| 		return relativeCacheDir() | 		return ".helmfile" | ||||||
| 	} | 	} | ||||||
| 	return filepath.Join(dir, defaultCacheDir) | 	return filepath.Join(dir, "helmfile") | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // TODO remove this function when rework on caching of remote helmfiles
 |  | ||||||
| func relativeCacheDir() string { |  | ||||||
| 	return fmt.Sprintf(".%s", defaultCacheDir) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Remote struct { | type Remote struct { | ||||||
|  | @ -293,9 +286,6 @@ func NewRemote(logger *zap.SugaredLogger, homeDir string, readFile func(string) | ||||||
| 	if remote.Home == "" { | 	if remote.Home == "" { | ||||||
| 		// Use for remote charts
 | 		// Use for remote charts
 | ||||||
| 		remote.Home = CacheDir() | 		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 | 	return remote | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue