# File lib/r10k/action/runner.rb, line 11 def initialize(opts, argv, klass) @opts = opts @argv = argv @klass = klass @settings = {} end
# File lib/r10k/action/runner.rb, line 28 def call setup_logging setup_settings # @todo check arguments setup_authorization instance.call end
# File lib/r10k/action/runner.rb, line 19 def instance if @_instance.nil? iopts = @opts.dup iopts.delete(:loglevel) @_instance = @klass.new(iopts, @argv, @settings) end @_instance end
# File lib/r10k/action/runner.rb, line 36 def setup_logging if @opts.key?(:loglevel) R10K::Logging.level = @opts[:loglevel] end end
# File lib/r10k/action/runner.rb, line 42 def setup_settings config_settings = settings_from_config(@opts[:config]) overrides = {:cachedir => @opts[:cachedir]} overrides.delete_if { |_, val| val.nil? } with_overrides = config_settings.merge(overrides) do |key, oldval, newval| logger.debug2 _("Overriding config file setting '%{key}': '%{old_val}' -> '%{new_val}'") % {key: key, old_val: oldval, new_val: newval} newval end @settings = R10K::Settings.global_settings.evaluate(with_overrides) R10K::Initializers::GlobalInitializer.new(@settings).call rescue R10K::Settings::Collection::ValidationError => e logger.error e.format exit(8) end
# File lib/r10k/action/runner.rb, line 75 def settings_from_config(override_path) loader = R10K::Settings::Loader.new path = loader.search(override_path) results = {} if path @opts[:config] = path logger.debug2 _("Reading configuration from %{config_path}") % {config_path: path.inspect} results = loader.read(path) else logger.debug2 _("No config file explicitly given and no default config file could be found, default settings will be used.") end results end