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