class R10K::Settings::Loader

Look for the r10k configuration file in standard locations.

r10k.yaml is checked for in the following locations:

- $PWD/r10k.yaml
- /etc/puppetlabs/r10k/r10k.yaml
- /etc/r10k.yaml

Constants

CONFIG_FILE
DEFAULT_LOCATION
OLD_DEFAULT_LOCATION

Attributes

loadpath[R]

Public Class Methods

new() click to toggle source
# File lib/r10k/settings/loader.rb, line 27
def initialize
  @loadpath = []
  populate_loadpath
end

Public Instance Methods

read(override = nil) click to toggle source
# File lib/r10k/settings/loader.rb, line 59
def read(override = nil)
  path = search(override)

  if path.nil?
    raise ConfigError, "No configuration file given, no config file found in current directory, and no global config present"
  end

  begin
    contents = ::YAML.load_file(path)
  rescue => e
    raise ConfigError, "Couldn't load config file: #{e.message}"
  end

  R10K::Util::SymbolizeKeys.symbolize_keys!(contents, true)
  contents
end

Private Instance Methods

populate_loadpath() click to toggle source
# File lib/r10k/settings/loader.rb, line 78
def populate_loadpath

  # Add the current directory for r10k.yaml
  @loadpath << File.join(Dir.getwd, CONFIG_FILE)

  # Add the AIO location for of r10k.yaml
  @loadpath << DEFAULT_LOCATION

  # Add the old default location last.
  @loadpath << OLD_DEFAULT_LOCATION

  @loadpath
end