choria-io / go-choria

Backplane Development Framework and Server hosting Choria Agents, Networks, Federations and Streaming Data
Apache License 2.0
86 stars 30 forks source link

Support XDG configuration locations #1624

Open ripienaar opened 2 years ago

ripienaar commented 2 years ago

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

We then merge:

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

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:

We then merge:

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 commented 2 years ago

Hitlist here is basically:

smortex commented 2 years ago

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 commented 2 years ago

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