[openstreetmap/openstreetmap-website] Use Config gem to read and validate configuration settings (#2177)

Andy Allan notifications at github.com
Wed Mar 13 17:34:29 UTC 2019


Fixes #2169. See also #2170 for an earlier attempt.

This PR replaces our application.yml based settings management with the [Config](https://github.com/railsconfig/config/) gem.

* Default settings are now in `config/settings.yml`
* You can override these settings by creating `config/settings.local.yml` with the particular settings you need to override.
* We can therefore add new settings in the future and they will just work
* Some settings are now validated. More could be validated in the future.
* The STATUS constant is now only read from the environment, since we need to know it before loading rails and before the configuration settings are read. You can run e.g. `STATUS=database_offline bundle exec rails server`
* The application will not start if it finds `config/application.yml`. You'll receive an helpful error message explaining what to do.

I've included this guard in case developers aren't aware of these changes, to avoid them running the updated code and not realising that their custom settings in application.yml are being completely ignored. If you want to have a zero-downtime change to the new way of configuring, then:
* Before deploying this code, configure your deployment environment to create `config/settings.local.yml` - this only needs the settings you want to override. It will be ignored by older codebases.
* Also, configure your deployment environment to remove `config/application.yml` if the default settings file `config/settings.yml` exists - it will appear after this PR is merged.
* Then you should be fine to deploy versions of the app both before and after this change as you see fit.


You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/2177

-- Commit Summary --

  * Install config gem for settings management
  * Move all settings to settings.yml
  * Drop the old environment variable parsing
  * Only take the STATUS configuration from the environment
  * Instruct sprockets to recompile this file based on the settings files changing
  * Update documentation for new approach to settings
  * Add some settings validations
  * Provide a helpful warning if there's an application.yml file detected

-- File Changes --

    M .gitignore (4)
    M CONFIGURE.md (12)
    M Gemfile (1)
    M Gemfile.lock (34)
    M INSTALL.md (10)
    M app/assets/javascripts/embed.js.erb (4)
    M app/assets/javascripts/osm.js.erb (27)
    M app/controllers/api/amf_controller.rb (2)
    M app/controllers/api/map_controller.rb (6)
    M app/controllers/api/notes_controller.rb (4)
    M app/controllers/api/tracepoints_controller.rb (4)
    M app/controllers/application_controller.rb (14)
    M app/controllers/diary_entries_controller.rb (6)
    M app/controllers/geocoder_controller.rb (18)
    M app/controllers/messages_controller.rb (2)
    M app/controllers/oauth_controller.rb (2)
    M app/controllers/traces_controller.rb (4)
    M app/controllers/users_controller.rb (8)
    M app/helpers/notifier_helper.rb (2)
    M app/mailers/notifier.rb (8)
    M app/models/client_application.rb (2)
    M app/models/request_token.rb (2)
    M app/models/trace.rb (6)
    M app/models/user.rb (4)
    M app/models/user_block.rb (2)
    M app/models/way.rb (2)
    M app/views/api/capabilities/show.builder (22)
    M app/views/layouts/_head.html.erb (4)
    M app/views/notifier/email_confirm.html.erb (2)
    M app/views/notifier/email_confirm.text.erb (2)
    M app/views/notifier/signup_confirm.html.erb (2)
    M app/views/notifier/signup_confirm.text.erb (2)
    M app/views/site/_id.html.erb (2)
    M app/views/site/_potlatch2.html.erb (4)
    M app/views/site/id.html.erb (4)
    M app/views/users/account.html.erb (2)
    M app/views/users/blocked.html.erb (2)
    M app/views/users/login.html.erb (10)
    M app/views/users/suspended.html.erb (2)
    M config/.gitignore (1)
    M config/application.rb (36)
    M config/environments/production.rb (2)
    D config/example.application.yml (146)
    M config/initializers/action_mailer.rb (4)
    M config/initializers/canonical_rails.rb (6)
    A config/initializers/config.rb (53)
    M config/initializers/omniauth.rb (16)
    M config/initializers/paperclip.rb (2)
    M config/initializers/secure_headers.rb (6)
    M config/initializers/session_store.rb (4)
    D config/preinitializer.rb (17)
    A config/settings.yml (122)
    A config/settings/development.yml (0)
    A config/settings/production.yml (0)
    A config/settings/test.yml (16)
    M lib/auth.rb (10)
    M lib/bounding_box.rb (2)
    M lib/osm.rb (16)
    M test/controllers/api/capabilities_controller_test.rb (10)
    M test/controllers/api/changes_controller_test.rb (6)
    M test/controllers/api/changesets_controller_test.rb (16)
    M test/controllers/api/map_controller_test.rb (10)
    M test/controllers/api/relations_controller_test.rb (2)
    M test/controllers/api/tracepoints_controller_test.rb (2)
    M test/controllers/api/traces_controller_test.rb (18)
    M test/controllers/messages_controller_test.rb (9)
    M test/controllers/site_controller_test.rb (10)
    M test/controllers/traces_controller_test.rb (18)
    M test/integration/user_blocks_test.rb (10)
    M test/integration/user_terms_seen_test.rb (4)
    M test/models/trace_test.rb (22)
    M test/models/way_test.rb (2)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/2177.patch
https://github.com/openstreetmap/openstreetmap-website/pull/2177.diff

-- 
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/pull/2177
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190313/bada67f4/attachment-0001.html>


More information about the rails-dev mailing list