Class: R10K::Source::Yamldir
- Defined in:
- lib/r10k/source/yamldir.rb
Constant Summary
Constants included from Logging
Instance Attribute Summary
Attributes inherited from Base
#basedir, #name, #prefix, #puppetfile_name
Instance Method Summary collapse
-
#initialize(name, basedir, options = {}) ⇒ Yamldir
constructor
A new instance of Yamldir.
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 = {}) ⇒ Yamldir
Returns a new instance of Yamldir.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/r10k/source/yamldir.rb', line 4 def initialize(name, basedir, = {}) config = [:config] || '/etc/puppetlabs/r10k/environments.d' unless File.directory?(config) raise R10K::Deployment::Config::ConfigError, _("Error opening %{dir}: config must be a directory") % {dir: config} end unless File.readable?(config) raise R10K::Deployment::Config::ConfigError, _("Error opening %{dir}: permission denied") % {dir: config} end environment_data = Dir.glob(File.join(config, '*.yaml')).reduce({}) do |memo,path| name = File.basename(path, '.yaml') begin contents = ::YAML.load_file(path) rescue => e raise R10K::Deployment::Config::ConfigError, _("Error loading %{path}: %{err}") % {path: path, err: e.} end memo.merge({name => contents }) end # Set the environments key for the parent class to consume [:environments] = environment_data # 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, ) end |