2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/puppet/data_providers/data_function_support.rb', line 2
def initialize_data(data_key, lookup_invocation)
name = "#{data_key}::data"
scope = lookup_invocation.scope
Puppet::Util::Profiler.profile("Called #{name}", [ :functions, name ]) do
loader = loader(data_key, scope)
if loader && func = loader.load(:function, name)
result = func.call(scope)
unless result.is_a?(Hash)
raise Puppet::Error.new("Expected '#{name}' function to return a Hash, got #{result.class}")
end
result = yield(result) if block_given?
else
raise Puppet::Error.new("Cannot find the function '#{name}' - required when using 'function' data provider scheme")
end
result
end
end
|