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

Use xdg basedir spec on linux #9007

Open
ogarcia opened this issue Apr 6, 2020 · 6 comments
Open

Use xdg basedir spec on linux #9007

ogarcia opened this issue Apr 6, 2020 · 6 comments
Labels

Comments

@ogarcia
Copy link

ogarcia commented Apr 6, 2020

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Instead of ~/.packer.d, configuration should be in the $XDG_CONFIG_HOME/packer/ and cache (safely-deletable files) should be in $XDG_CACHE_HOME/packer.

@nywilken nywilken added the core Core components of Packer label Apr 6, 2020
@nywilken
Copy link
Contributor

nywilken commented Apr 6, 2020

Hi @ogarcia thanks for reaching out here. Packer, along with other HashiCorp tools, have standardized around the use of a placing the product configuration files on ~/<product>.d/ (*nix) or %APPDATA%/<product>.d/ for Windows systems. But Packer does allow users to override those settings with the use of environment variables https://packer.io/docs/other/environment-variables.html

By setting PACKER_CONFIG_DIR=$XDG_CONFIG_HOME/packer/ and PACKER_CACHE_DIR=$XDG_CACHE_HOME/packer/ you should be able accomplish what you are requesting in this issue. If the new information on how to override the default settings for Packer are sufficient feel free to close this issue. Or leave a comment if you would like to discuss further. Cheers!

@ogarcia
Copy link
Author

ogarcia commented Apr 7, 2020

Hi @nywilken thanks for your quick response! But if cache and config dir are well supported, why is not the default behavior use the XDG spec?

I think that the implementation is simple in this case. For Linux systems:

  • For ${XDG_CONFIG_HOME}, if variable is defined, use it, else use ${HOME}/.config.
  • For ${XDG_CACHE_HOME}, if variable is defined, use it, else use ${HOME}/.cache.

Sample in bash:

export PACKER_CONFIG_DIR=${XDG_CONFIG_HOME:-${HOME}/.config}/packer
export PACKER_CACHE_DIR=${XDG_CACHE_HOME:-${HOME}/.cache}/packer

@teddylear
Copy link
Contributor

I can take a look into this.

@SwampDragons
Copy link
Contributor

That would be great!

@teddylear
Copy link
Contributor

@SwampDragons I believe I have addressed issue in attached PR, but had issues issues with testing os specific paths. Please see comment on PR about issue, any ideas for testing welcome!

@tony-sol
Copy link

Current content of $XDG_CONFIG_HOME/packer/ isn't actually a config, it's more like a data/state, so i guess files like checkpoint_cache and checkpoint_signature should be placed either in XDG_CACHE_HOME and XDG_STATE_HOME, or PACKER_CONFIG_DIR should be renamed into PACKER_HOME_DIR as well it has all types of state by default (by default - i mean, without any other sets of PACKER_CACHE_DIR or PACKER_PLUGIN_PATH, which are actually inconsistent in theirs namings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants