Class: R10K::Action::Runner
- Inherits:
-
Object
- Object
- R10K::Action::Runner
show all
- Includes:
- Logging
- Defined in:
- lib/r10k/action/runner.rb
Constant Summary
Constants included
from Logging
Logging::LOG_LEVELS
Instance Method Summary
collapse
Methods included from Logging
debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(opts, argv, klass) ⇒ Runner
Returns a new instance of Runner.
11
12
13
14
15
16
17
|
# File 'lib/r10k/action/runner.rb', line 11
def initialize(opts, argv, klass)
@opts = opts
@argv = argv
@klass = klass
@settings = {}
end
|
Instance Method Details
#call ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/r10k/action/runner.rb', line 28
def call
setup_logging
setup_settings
setup_authorization
instance.call
end
|
#instance ⇒ Object
19
20
21
22
23
24
25
26
|
# 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
|
#setup_authorization ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/r10k/action/runner.rb', line 65
def setup_authorization
begin
license = R10K::Util::License.load
if license.respond_to?(:authorization_token)
PuppetForge::Connection.authorization = license.authorization_token
end
rescue R10K::Error => e
logger.warn e.message
end
end
|
#setup_logging ⇒ Object
36
37
38
39
40
|
# File 'lib/r10k/action/runner.rb', line 36
def setup_logging
if @opts.key?(:loglevel)
R10K::Logging.level = @opts[:loglevel]
end
end
|
#setup_settings ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/r10k/action/runner.rb', line 42
def setup_settings
config_settings = settings_from_config(@opts[:config])
overrides = {}
overrides[:cachedir] = @opts[:cachedir] unless @opts[:cachedir].nil?
overrides[:deploy] = {} if @opts[:'puppet-path'] || @opts[:'generate-types']
overrides[:deploy][:puppet_path] = @opts[:'puppet-path'] unless @opts[:'puppet-path'].nil?
overrides[:deploy][:generate_types] = @opts[:'generate-types'] unless @opts[:'generate-types'].nil?
with_overrides = config_settings.merge(overrides) do |key, oldval, newval|
newval = oldval.merge(newval) if oldval.is_a? Hash
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
|