]> git.openstreetmap.org Git - rails.git/blob - config/initializers/config.rb
Merge remote-tracking branch 'upstream/pull/1926'
[rails.git] / config / initializers / config.rb
1 # Guard against deployments with old-style application.yml configurations
2 # Otherwise, admins might not be aware that they are now silently ignored
3 # and major problems could occur
4 # rubocop:disable Rails/Output, Rails/Exit
5 if File.exist?(Rails.root.join("config", "application.yml"))
6   puts "The config/application.yml file is no longer supported."
7   puts ""
8   puts "Default settings are now found in config/settings.yml and you"
9   puts "can override these in config/settings.local.yml."
10   puts ""
11   puts "To prevent unexpected behaviour, please copy any custom"
12   puts "settings to config/settings.local.yml and then remove"
13   puts "your config/application.yml file."
14   exit!
15 end
16 # rubocop:enable Rails/Output, Rails/Exit
17
18 # Allowed status values
19 ALLOWED_STATUS ||= [
20   "online",            # online and operating normally
21   "api_readonly",      # site online but API in read-only mode
22   "api_offline",       # site online but API offline
23   "database_readonly", # database and site in read-only mode
24   "database_offline",  # database offline with site in emergency mode
25   "gpx_offline"        # gpx storage offline
26 ].freeze
27
28 Config.setup do |config|
29   # Name of the constant exposing loaded settings
30   config.const_name = "Settings"
31
32   # Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
33   #
34   # config.knockout_prefix = nil
35
36   # Overwrite an existing value when merging a `nil` value.
37   # When set to `false`, the existing value is retained after merge.
38   #
39   # config.merge_nil_values = true
40
41   # Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
42   #
43   # config.overwrite_arrays = true
44
45   # Load environment variables from the `ENV` object and override any settings defined in files.
46   #
47   config.use_env = true
48
49   # Define ENV variable prefix deciding which variables to load into config.
50   #
51   config.env_prefix = "OPENSTREETMAP"
52
53   # What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
54   # with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
55   # using dots in variable names might not be allowed (eg. Bash).
56   #
57   config.env_separator = "_"
58
59   # Ability to process variables names:
60   #   * nil  - no change
61   #   * :downcase - convert to lower case
62   #
63   config.env_converter = :downcase
64
65   # Parse numeric values as integers instead of strings.
66   #
67   # config.env_parse_values = true
68
69   # Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
70   #
71   config.schema do
72     required(:api_version).filled(:str?)
73     required(:max_request_area).filled(:number?)
74     required(:max_note_request_area).filled(:number?)
75     required(:tracepoints_per_page).filled(:int?)
76     required(:max_number_of_way_nodes).filled(:int?)
77     required(:api_timeout).filled(:int?)
78     required(:imagery_blacklist).maybe(:array?)
79     required(:status).filled(:str?, :included_in? => ALLOWED_STATUS)
80     required(:storage_service).filled(:str?)
81   end
82 end