class R10K::Source::Yaml

Public Class Methods

new(name, basedir, options = {}) click to toggle source
Calls superclass method R10K::Source::Hash::new
# 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 R10K::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