Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TIMONI_CACHE_DIR variable as another method to set the cache location #475

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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