Class: HieraLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/hiera_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, config = 'hiera.yaml') ⇒ HieraLoader

Returns a new instance of HieraLoader.



21
22
23
24
# File 'lib/hiera_loader.rb', line 21

def initialize(scope, config = 'hiera.yaml')
    @hiera = Hiera.new(:config => config)
    @scope = scope
end

Instance Attribute Details

#hieraObject

Returns the value of attribute hiera.



19
20
21
# File 'lib/hiera_loader.rb', line 19

def hiera
  @hiera
end

#scopeObject

Returns the value of attribute scope.



19
20
21
# File 'lib/hiera_loader.rb', line 19

def scope
  @scope
end

Instance Method Details

#get_config(key, is_required = true) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/hiera_loader.rb', line 26

def get_config(key, is_required=true)
    val = @hiera.lookup(key, nil, @scope)
    if is_required == true and !val
        puts "Required config #{key} not found. Please provide."
        raise "Required config #{key} not found. Please provide."
    end
    val
end