lib/bolt/config.rb in bolt-2.18.0 vs lib/bolt/config.rb in bolt-2.19.0
- old
+ new
@@ -17,11 +17,11 @@
end
class Config
include Bolt::Config::Options
- attr_reader :config_files, :warnings, :data, :transports, :project, :modified_concurrency
+ attr_reader :config_files, :warnings, :data, :transports, :project, :modified_concurrency, :deprecations
BOLT_CONFIG_NAME = 'bolt.yaml'
BOLT_DEFAULTS_NAME = 'bolt-defaults.yaml'
# The default concurrency value that is used when the ulimit is not low (i.e. < 700)
@@ -39,11 +39,12 @@
end
data = load_defaults(project).push(
filepath: project.config_file,
data: conf,
- warnings: []
+ warnings: [],
+ deprecations: []
)
new(project, data, overrides)
end
@@ -57,11 +58,12 @@
end
data = load_defaults(project).push(
filepath: project.config_file,
data: conf,
- warnings: []
+ warnings: [],
+ deprecations: []
)
new(project, data, overrides)
end
@@ -138,22 +140,23 @@
end
data = data.merge(data.delete('inventory-config'))
end
- { filepath: filepath, data: data, warnings: warnings }
+ { filepath: filepath, data: data, warnings: warnings, deprecations: [] }
end
# Loads a 'bolt.yaml' file, the legacy configuration file. There's no special munging needed
# here since Bolt::Config will just ignore any invalid keys.
def self.load_bolt_yaml(dir)
filepath = dir + BOLT_CONFIG_NAME
data = Bolt::Util.read_yaml_hash(filepath, 'config')
- warnings = [msg: "Configuration file #{filepath} is deprecated and will be removed in a future version "\
- "of Bolt. Use '#{dir + BOLT_DEFAULTS_NAME}' instead."]
+ deprecations = [{ type: 'Using bolt.yaml for system configuration',
+ msg: "Configuration file #{filepath} is deprecated and will be removed in a future version "\
+ "of Bolt. Use '#{dir + BOLT_DEFAULTS_NAME}' instead." }]
- { filepath: filepath, data: data, warnings: warnings }
+ { filepath: filepath, data: data, warnings: [], deprecations: deprecations }
end
def self.load_defaults(project)
confs = []
@@ -180,16 +183,20 @@
confs
end
def initialize(project, config_data, overrides = {})
unless config_data.is_a?(Array)
- config_data = [{ filepath: project.config_file, data: config_data, warnings: [] }]
+ config_data = [{ filepath: project.config_file,
+ data: config_data,
+ warnings: [],
+ deprecations: [] }]
end
@logger = Logging.logger[self]
@project = project
@warnings = @project.warnings.dup
+ @deprecations = @project.deprecations.dup
@transports = {}
@config_files = []
default_data = {
'apply_settings' => {},
@@ -206,10 +213,11 @@
'transport' => 'ssh'
}
loaded_data = config_data.each_with_object([]) do |data, acc|
@warnings.concat(data[:warnings]) if data[:warnings].any?
+ @deprecations.concat(data[:deprecations]) if data[:deprecations].any?
if data[:data].any?
@config_files.push(data[:filepath])
acc.push(data[:data])
end
@@ -376,10 +384,10 @@
compile_limit = 2 * Etc.nprocessors
unless compile_concurrency < compile_limit
raise Bolt::ValidationError, "Compilation is CPU-intensive, set concurrency less than #{compile_limit}"
end
- if (format == 'rainbow' && Bolt::Util.windows?) || !(%w[human json rainbow].include? format)
+ unless %w[human json rainbow].include? format
raise Bolt::ValidationError, "Unsupported format: '#{format}'"
end
Bolt::Util.validate_file('hiera-config', @data['hiera-config']) if @data['hiera-config']
Bolt::Util.validate_file('trusted-external-command', trusted_external) if trusted_external