Class: R10K::Source::Yaml

Inherits:
Hash show all
Defined in:
lib/r10k/source/yaml.rb

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#basedir, #name, #prefix, #puppetfile_name

Instance Method Summary collapse

Methods inherited from Hash

#desired_contents, #environments, #environments_hash, #set_environments_hash, valid_environments_hash?

Methods inherited from Base

#accept, #environments, #preload!, #reload!

Methods included from Logging

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

Constructor Details

#initialize(name, basedir, options = {}) ⇒ Yaml

Returns a new instance of Yaml.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/r10k/source/yaml.rb', line 4

def initialize(name, basedir, options = {})
  config = options[:config] || '/etc/puppetlabs/r10k/environments.yaml'

  begin
    contents = ::YAML.load_file(config)
  rescue => e
    raise ConfigError, _("Couldn't open environments file %{file}: %{err}") % {file: config, err: e.message}
  end

  # Set the environments key for the parent class to consume
  options[:environments] = contents

  # All we need to do is supply options with the :environments hash.
  # The R10K::Source::Hash parent class takes care of the rest.
  super(name, basedir, options)
end