Skip to content

Commit

Permalink
lib: Add $COCKPIT_IMAGES_DATA_DIR env variable
Browse files Browse the repository at this point in the history
Similarly to commit 85b0db4 and commit 6b7864a, this lets
us configure the image cache volume in one place (job-runner.toml),
instead of having to hardcode it in the tasks Containerfile. This will
replace
https://github.com/cockpit-project/cockpituous/blob/accb1fdc6a/tasks/Containerfile#L73
  • Loading branch information
martinpitt committed Mar 7, 2024
1 parent 6aa2b40 commit a831237
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ For running and debugging the images:
## Image location

Downloaded images are stored into ~/.cache/cockpit-images/ by default. If you
want to change that, you can set the `cockpit.bots.images-data-dir` variable
with `git config` to a directory where to store the pristine virtual machine
images. For example:
want to change that, you can set `$COCKPIT_IMAGES_DATA_DIR` or the
`cockpit.bots.images-data-dir` variable with `git config` to a directory where
to store the pristine virtual machine images. For example:

git config cockpit.bots.images-data-dir /srv/cockpit/images

Expand Down
8 changes: 5 additions & 3 deletions lib/directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def get_images_data_dir() -> str:
global _images_data_dir

if _images_data_dir is None:
_images_data_dir = get_git_config('--type=path', 'cockpit.bots.images-data-dir')

_images_data_dir = os.getenv('COCKPIT_IMAGES_DATA_DIR')
if _images_data_dir is None:
_images_data_dir = xdg_cache_home('cockpit-images')
_images_data_dir = get_git_config('--type=path', 'cockpit.bots.images-data-dir')

if _images_data_dir is None:
_images_data_dir = xdg_cache_home('cockpit-images')

return _images_data_dir

0 comments on commit a831237

Please sign in to comment.