Class: Hiera::Config
- Inherits:
-
Object
- Object
- Hiera::Config
- Defined in:
- lib/hiera/config.rb
Class Method Summary collapse
- .[](key) ⇒ Object
- .include?(key) ⇒ Boolean
-
.load(source) ⇒ Object
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.
- .load_backends ⇒ Object
Class Method Details
.[](key) ⇒ Object
47 48 49 |
# File 'lib/hiera/config.rb', line 47 def [](key) @config[key] end |
.include?(key) ⇒ Boolean
43 44 45 |
# File 'lib/hiera/config.rb', line 43 def include?(key) @config.include?(key) end |
.load(source) ⇒ Object
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
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/hiera/config.rb', line 8 def load(source) @config = {:backends => "yaml", :hierarchy => "common"} if source.is_a?(String) raise "Config file #{source} not found" unless File.exist?(source) config = YAML.load_file(source) @config.merge! config if config 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 |