Sha256: 4bc61b70b048e57b0156440208ea9285be7f7838f9cb2d756e738931702c933d
Contents?: true
Size: 1.29 KB
Versions: 6
Compression:
Stored size: 1.29 KB
Contents
class Hiera::Config class << self # Takes a string or hash as input, strings are treated as filenames # hashes are stored as data that would have been in the config file # # Unless specified it will only use YAML as backend with a single # 'common' hierarchy and console logger def load(source) @config = {:backends => "yaml", :hierarchy => "common"} if source.is_a?(String) if File.exist?(source) config = YAML.load_file(source) @config.merge! config if config else raise "Config file #{source} not found" end elsif source.is_a?(Hash) @config.merge! source end @config[:backends] = [ @config[:backends] ].flatten if @config.include?(:logger) Hiera.logger = @config[:logger].to_s else @config[:logger] = "console" Hiera.logger = "console" end @config end def load_backends @config[:backends].each do |backend| begin require "hiera/backend/#{backend.downcase}_backend" rescue LoadError => e Hiera.warn "Cannot load backend #{backend}: #{e}" end end end def include?(key) @config.include?(key) end def [](key) @config[key] end end end
Version data entries
6 entries across 6 versions & 1 rubygems