def lookup(key, scope, order_override, resolution_type)
answer = nil
parse_options(scope)
debug("Looking up #{key} in eYAML backend")
Backend.datasources(scope, order_override) do |source|
debug("Looking for data source #{source}")
eyaml_file = Backend.datafile(:eyaml, scope, source, extension) || next
next unless File.exists?(eyaml_file)
data = @cache.read(eyaml_file, Hash) do |data|
YAML.load(data) || {}
end
next if data.empty?
next unless data.include?(key)
debug("Found #{key} in #{source}")
new_answer = parse_answer(data[key], scope)
case resolution_type
when :array
raise Exception, "Hiera type mismatch: expected Array and got #{new_answer.class}" unless new_answer.kind_of? Array or new_answer.kind_of? String
answer ||= []
answer << new_answer
when :hash
raise Exception, "Hiera type mismatch: expected Hash and got #{new_answer.class}" unless new_answer.kind_of? Hash
answer ||= {}
answer = Backend.merge_answer(new_answer,answer)
else
answer = new_answer
break
end
end
return answer
end