class Covalence::HieraDB::Client

TODO: maybe HieraWrapper :reek: DataClump

Attributes

scope[R]

Public Class Methods

new(config, scope = {}) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 12
def initialize(config, scope = {})
  @config = config
  @scope = scope

  begin
    @client = Hiera.new(:config => config)
  rescue RuntimeError => e
    Covalence::LOGGER.error e.message
    exit 1
  end
end

Public Instance Methods

array_lookup(key, default = nil, scope = @scope) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 45
def array_lookup(key, default = nil, scope = @scope)
  @client.lookup(key, default, scope, nil, :array)
end
hash_lookup(key, default = nil, scope = @scope) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 39
def hash_lookup(key, default = nil, scope = @scope)
  # https://github.com/puppetlabs/hiera/blob/d7ed74f4eec8f4fb1aa84cd0e158a595f86debd4/lib/hiera/backend.rb#L241
  # def lookup(key, default, scope, order_override, resolution_type, context = {:recurse_guard => nil})
  @client.lookup(key, default, scope, nil, :hash)
end
initialize_scope(scope) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 24
def initialize_scope(scope)
  self.class.new(@config, scope)
end
lookup(key, default = nil, scope = @scope) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 35
def lookup(key, default = nil, scope = @scope)
  @client.lookup(key, default, scope)
end
set_scope(env, stack) click to toggle source
# File lib/covalence/core/data_stores/hiera.rb, line 28
def set_scope(env, stack)
  @scope = {
    "environment" => env,
    "stack" => stack
  }
end