[openstreetmap/openstreetmap-website] Reduce papercuts when changing configuration settings (#2169)
Andy Allan
notifications at github.com
Wed Mar 6 15:48:13 UTC 2019
>From time to time we change the required configuration settings that are expected to be found in `config/application.yml`, for example by adding a new key. This can cause trivial-but-annoying errors for developers. In particular, the updated application might run fine until you hit one particular page that requires the new key. This isn't picked up on in the tests, since they use the `config.application.example.yml` file, nor on application boot. When you hit the problem, the error is a bit cryptic too.
I've investigated using off-the-shelf configuration management gems, with an eye to replacing our custom preinitializer-and-constants based approach. Criteria include:
* Support for configuration settings from yaml files
* Support for overriding settings using environment variables
* Support for our custom all-in-one existing yaml approach
* Support for non-string settings (like integers and floats)
* Validation of settings (e.g. flagging up required values at boot, ensuring certain settings are numerical)
* Allow settings to be missing (e.g. the oauth_keys, where you need to boot the app to register for consumer tokens)
* Is the gem maintained etc
I've had previous experience with [Figaro](https://github.com/laserlemon/figaro), but it treats all settings as strings, and doesn't have any built-in conversions or validation. The solution for validation and conversion could then be to use an initializer to populate the [Rails custom settings](https://guides.rubyonrails.org/configuring.html#custom-configuration). Figaro also lacks any obvious way to convert our existing application.yml into the expected yaml format.
I've been exploring the [Config](https://github.com/railsconfig/config/) gem today, and I can get it mostly working, but there's a few rough edges in there too. I'll open a PR shortly.
I'd also like to hear if anyone else has thoughts on different approaches to this problem, or different criteria that should be considered, or things that I've overlooked.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2169
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190306/a4bfa52b/attachment.html>
More information about the rails-dev
mailing list