Skip to content

Commit

Permalink
Merge pull request #475 from folliehiyuki/timoni-env-cache-dir
Browse files Browse the repository at this point in the history
Add TIMONI_CACHE_DIR variable as another method to set the cache location
  • Loading branch information
stefanprodan authored Feb 8, 2025
2 parents 0027449 + 530c3da commit 734e12d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions cmd/timoni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,17 @@ func setCacheDir() {
return
}
if rootArgs.cacheDir == "" {
home, err := os.UserHomeDir()
if err != nil {
return
cacheDir := os.Getenv("TIMONI_CACHE_DIR")

if cacheDir == "" {
home, err := os.UserHomeDir()
if err != nil {
return
}
rootArgs.cacheDir = path.Join(home, ".timoni/cache")
} else {
rootArgs.cacheDir = cacheDir
}
rootArgs.cacheDir = path.Join(home, ".timoni/cache")
}

if err := os.MkdirAll(rootArgs.cacheDir, os.ModePerm); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ Timoni maintains a local cache of modules pulled from remote container registrie
Cashing is meant to reduce network traffic for sequential pull operations and speeds up
applying bundles which refer to modules with identical layers.

The default cache location is `$HOME/.timoni/cache` and be changed with the `--cache-dir` global flag.
The default cache location is `$HOME/.timoni/cache` and can be changed with either the
`--cache-dir` global flag or `TIMONI_CACHE_DIR` environment variable. The global flag
takes precedence over the environment variable.

If the home directory is not writable, caching can be disabled by
setting the `TIMONI_CACHING=false` environment variable.
Expand Down

0 comments on commit 734e12d

Please sign in to comment.