Class: R10K::Deployment::Config Private

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/deployment/config.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ConfigError

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

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

Constructor Details

#initialize(configfile, overrides = {}) ⇒ Config

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Config.



16
17
18
19
20
21
# File 'lib/r10k/deployment/config.rb', line 16

def initialize(configfile, overrides={})
  @configfile = configfile
  @overrides = overrides

  load_config
end

Instance Attribute Details

#configfileObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/r10k/deployment/config.rb', line 14

def configfile
  @configfile
end

Instance Method Details

#load_configObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load and store a config file, and set relevant options

Parameters:

  • configfile (String)

    The path to the YAML config file



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/r10k/deployment/config.rb', line 37

def load_config
  loader = R10K::Settings::Loader.new
  hash = loader.read(@configfile)

  with_overrides = hash.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

  @config = R10K::Settings.global_settings.evaluate(with_overrides)

  initializer = R10K::Initializers::GlobalInitializer.new(@config)
  initializer.call
end

#setting(key) ⇒ Object Also known as: []

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Perform a scan for key and check for both string and symbol keys



24
25
26
# File 'lib/r10k/deployment/config.rb', line 24

def setting(key)
  @config[key]
end

#settingsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/r10k/deployment/config.rb', line 30

def settings
  @config
end