Method: Bolt::Config#merge_config_layers

Defined in:
lib/bolt/config.rb

#merge_config_layers(*config_data) ⇒ Object

Merge configuration from all sources into a single hash. Precedence from lowest to highest: defaults, system-wide, user-level, project-level, CLI overrides



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/bolt/config.rb', line 251

def merge_config_layers(*config_data)
  config_data.inject({}) do |acc, config|
    acc.merge(config) do |key, val1, val2|
      case key
      # Plugin config is shallow merged for each plugin
      when 'plugins'
        val1.merge(val2) { |_, v1, v2| v1.merge(v2) }
      # Transports are deep merged
      when *TRANSPORT_CONFIG.keys
        Bolt::Util.deep_merge(val1, val2)
      # Hash values are shallow merged
      when 'apply-settings', 'log', 'plugin-hooks', 'puppetdb'
        val1.merge(val2)
      # Disabled warnings are concatenated
      when 'disable-warnings'
        val1.concat(val2)
      when 'analytics'
        val1 && val2
      # All other values are overwritten
      else
        val2
      end
    end
  end
end