muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.28k stars 319 forks source link

Proposal: add user configuration directory to the config search path #283

Closed rubiojr closed 4 years ago

rubiojr commented 4 years ago

Beehive tries to load a beehive.conf from the current directory ./beehive.conf when booting (if found). If not found, it'll use an in-memory representation until the process exits cleanly, then write it to the current directory.

The proposal is to also search for a config using $os.UserConfigDir/beehive/beehive.conf, so ~/.config/beehive/beehive.conf under Linux for example (platform dependent).

With this change, Beehive would search for the config file in this particular order:

  1. The current working directory (i.e. the way it works now)
  2. $os.UserConfigDir/beehive/beehive.conf

The change would be backwards compatible.

I also thought about writing to $os.UserConfigDir/beehive instead of $CWD when there's no config present, which sounds harmless for the most part, but that'd change behavior in a backwards incompatible way.

Thoughts?

rubiojr commented 4 years ago

Forgot to mention that, as an additional benefit, this would open the door to have a dedicated config directory where we can store other things, like hive specific data.

muesli commented 4 years ago

I agree, I think it makes sense to follow the XDG specs here. A while ago I've actually written a little Go library that retrieves platform specific paths: https://github.com/muesli/go-app-paths/ - may come in handy here.