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

Support XDG configuration locations #1624

Open
ripienaar opened this issue Mar 24, 2022 · 3 comments
Open

Support XDG configuration locations #1624

ripienaar opened this issue Mar 24, 2022 · 3 comments

Comments

@ripienaar
Copy link
Member

ripienaar commented Mar 24, 2022

Today for users the configuration we search down till we find a config, first one wins:

  • ~/.choriarc
  • ~/.mcollective
  • for windows: c:\programdata\choria\etc\client.conf
  • /etc/choria/client.conf
  • /usr/local/etc/choria/client.conf
  • /etc/puppetlabs/mcollective/client.cfg

We then merge:

  • choria.conf in pwd and each ancestor directory

This is pretty crazy, but things are about to get worse as we have to consider:

  • The registry will need a cache for DDL files
  • Non CA based setups store ed25519 keys, jwt tokens etc

So we have to start thinking about data storage in client dirs etc

In linux world we have the XDG Base Directory Specification and I want to support this going forward as the way for user config.

So this means above list becomes:

  • on *nix ~/.config/choria/choria.conf
  • on windows C:\Users\username\AppData\Local aka LocalAppData or %LOCALAPPDATA%
  • for windows: c:\programdata\choria\etc\client.conf
  • /etc/choria/client.conf
  • /usr/local/etc/choria/client.conf

We then merge:

  • choria.conf in pwd and each ancestor directory

I will support old ones a bit but start warning about them I think.

For caches for registry we would then use XDG_CACHE_HOME aka ~/.cache/choria/registry by default and on windows LocalAppData\cache\choria\registry.

We can use the https://github.com/adrg/xdg package that includes the windows stuff as above.

Comments @smortex and @bastelfreak pls?

@ripienaar ripienaar changed the title Support XDG configuration format Support XDG configuration locations Mar 24, 2022
@ripienaar
Copy link
Member Author

Hitlist here is basically:

  • util.UserConfig() should first check XDG paths
  • Various updated in config.normalize() to check current setting and if not fall to XDG, mainly token and seed files
  • Add some helpers to confkey to resolve ie. we have ~/foo but maybe something like {{CACHE}}/registry would expand to ~/.cache/choria/registry

@smortex
Copy link
Member

smortex commented Apr 7, 2022

LGTM!

On the top of my head, if some variable substitution (i.e. CACHE in your message above) is allowed maybe it can be useful to interpolate other configuration settings. A use case would be for example to have the cache registry configured once in ~/.config/choria/choria.conf and set to {{CACHE}}/registry-{{plugin.choria.srv_domain}}; and then the choria.conf in the current working directory does not have to override it for each config?

@ripienaar
Copy link
Member Author

Interesting, certainly possible but would need to think about it, the configuration system is pretty overloaded with features already :)

I tend to solve that with project directories since your excellent choria.conf addition

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

No branches or pull requests

2 participants