Class: Puppet::DataProviders::FunctionEnvDataProvider

Inherits:
Plugins::DataProviders::EnvironmentDataProvider show all
Includes:
DataFunctionSupport
Defined in:
lib/puppet/data_providers/function_env_data_provider.rb

Overview

The FunctionEnvDataProvider provides data from a function called ‘environment::data()’ that resides in a directory environment (seen as a module with the name environment). The function is called on demand, and is associated with the compiler via an Adapter. This ensures that the data is only produced once per compilation.

Instance Method Summary collapse

Methods included from DataFunctionSupport

#data, #initialize_data_from_function

Instance Method Details

#loader(key, scope) ⇒ Object



24
25
26
27
# File 'lib/puppet/data_providers/function_env_data_provider.rb', line 24

def loader(key, scope)
  # This loader allows the data function to be private or public in the environment
  scope.compiler.loaders.private_environment_loader
end

#lookup(name, scope, merge) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/puppet/data_providers/function_env_data_provider.rb', line 14

def lookup(name, scope, merge)
  begin
    hash = data('environment', scope)
    throw :no_such_key unless hash.include?(name)
    hash[name]
  rescue *Puppet::Error => detail
    raise Puppet::DataBinding::LookupError.new(detail.message, detail)
  end
end