Module: ErbHiera::Hiera

Defined in:
lib/erb-hiera/hiera.rb

Class Method Summary collapse

Class Method Details

.get_bindingObject



47
48
49
# File 'lib/erb-hiera/hiera.rb', line 47

def self.get_binding
  binding
end

.hiera(key) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/erb-hiera/hiera.rb', line 5

def self.hiera(key)
  hiera = ::Hiera.new(:config => ErbHiera.options[:hiera_config])
  ::Hiera.logger = "noop"
  value = hiera.lookup(key, nil, ErbHiera.scope, nil, :priority)

  unless value
    puts "\nerror: cannot find value for key: #{key}"
    exit 1
  end

  puts "# #{key}: #{value}" if ErbHiera.options[:verbose]
  value
end

.hiera_array(key) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/erb-hiera/hiera.rb', line 19

def self.hiera_array(key)
  hiera = ::Hiera.new(:config => ErbHiera.options[:hiera_config])
  ::Hiera.logger = "noop"
  value = hiera.lookup(key, nil, ErbHiera.scope, nil, :array)

  unless value
    puts "\nerror: cannot find value for key: #{key}"
    exit 1
  end

  puts "# #{key}: #{value}" if ErbHiera.options[:verbose]
  value
end

.hiera_hash(key) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/erb-hiera/hiera.rb', line 33

def self.hiera_hash(key)
  hiera = ::Hiera.new(:config => ErbHiera.options[:hiera_config])
  ::Hiera.logger = "noop"
  value = hiera.lookup(key, nil, ErbHiera.scope, nil, :hash)

  unless value
    puts "\nerror: cannot find value for key: #{key}"
    exit 1
  end

  puts "# #{key}: #{value}" if ErbHiera.options[:verbose]
  value
end