Class: R10K::Action::Deploy::Module

Inherits:
Base
  • Object
show all
Includes:
DeployHelpers, Visitor
Defined in:
lib/r10k/action/deploy/module.rb

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitor

#visit

Methods included from Logging

debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Methods included from DeployHelpers

#check_write_lock!, #expect_config!

Constructor Details

#initialize(opts, argv, settings = {}) ⇒ Module

Note:

All arguments will be required in the next major version

Returns a new instance of Module.

Parameters:

  • opts (Hash)

    A hash of options defined in #allowed_initialized_opts and managed by the SetOps mixin within the Action::Base class. Corresponds to the CLI flags and options.

  • argv (Enumerable)

    Typically CRI::ArgumentList or Array. A list-like collection of the remaining arguments to the CLI invocation (after removing flags and options).

  • settings (Hash) (defaults to: {})

    A hash of configuration loaded from the relevant config (r10k.yaml).



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/r10k/action/deploy/module.rb', line 29

def initialize(opts, argv, settings = {})
  super

  requested_env = @opts[:environment] ? [@opts[:environment].gsub(/\W/, '_')] : []
  @modified_envs = []

  @settings = @settings.merge({
    overrides: {
      environments: {
        requested_environments: requested_env,
        generate_types: @generate_types
      },
      modules: {
        exclude_spec: settings.dig(:deploy, :exclude_spec),
        pool_size: @settings[:pool_size] || 4,
        requested_modules: @argv.map.to_a,
        # force here is used to make it easier to reason about
        force: !@no_force
      },
      forge: {
        allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
      },
      purging: {},
      output: {}
    }
  })
end

Instance Attribute Details

#forceObject (readonly)

Deprecated



15
16
17
# File 'lib/r10k/action/deploy/module.rb', line 15

def force
  @force
end

#settingsObject (readonly)

Returns the value of attribute settings.



17
18
19
# File 'lib/r10k/action/deploy/module.rb', line 17

def settings
  @settings
end

Instance Method Details

#callObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/r10k/action/deploy/module.rb', line 57

def call
  @visit_ok = true
  begin
    expect_config!
    deployment = R10K::Deployment.new(@settings)
    check_write_lock!(@settings)

    deployment.accept(self)
  rescue => e
    @visit_ok = false
    logger.error R10K::Errors::Formatting.format_exception(e, @trace)
  end

  @visit_ok
end