class Puppet::Pops::Lookup::ConfiguredDataProvider

@api private

Public Class Methods

new(config = nil) click to toggle source

@param config [HieraConfig,nil] the configuration

   # File lib/puppet/pops/lookup/configured_data_provider.rb
11 def initialize(config = nil)
12   @config = config.nil? ? nil : assert_config_version(config)
13 end

Public Instance Methods

config(lookup_invocation) click to toggle source
   # File lib/puppet/pops/lookup/configured_data_provider.rb
15 def config(lookup_invocation)
16   @config ||= assert_config_version(HieraConfig.create(lookup_invocation, configuration_path(lookup_invocation), self))
17 end
config=(config) click to toggle source

Needed to assign generated version 4 config @deprecated

   # File lib/puppet/pops/lookup/configured_data_provider.rb
21 def config=(config)
22   @config = config
23 end
config_path() click to toggle source

@return [Pathname] the path to the configuration

   # File lib/puppet/pops/lookup/configured_data_provider.rb
26 def config_path
27   @config.nil? ? nil : @config.config_path
28 end
name() click to toggle source

@return [String] the name of this provider

   # File lib/puppet/pops/lookup/configured_data_provider.rb
31 def name
32   n = "#{place} "
33   n << '"' << module_name << '" ' unless module_name.nil?
34   n << 'Data Provider'
35   n << " (#{@config.name})" unless @config.nil?
36   n
37 end
unchecked_key_lookup(key, lookup_invocation, merge) click to toggle source

Performs a lookup by searching all configured locations for the given key. A merge will be performed if the value is found in more than one location.

@param key [String] The key to lookup @param lookup_invocation [Invocation] The current lookup invocation @param merge [MergeStrategy,String,Hash{String => Object},nil] Merge strategy, merge strategy name, strategy and options hash, or nil (implies “first found”) @return [Object] the found object @throw :no_such_key when the object is not found

   # File lib/puppet/pops/lookup/configured_data_provider.rb
47 def unchecked_key_lookup(key, lookup_invocation, merge)
48   lookup_invocation.with(:data_provider, self) do
49     merge_strategy = MergeStrategy.strategy(merge)
50     dps = data_providers(lookup_invocation)
51     if dps.empty?
52       lookup_invocation.report_not_found(key)
53       throw :no_such_key
54     end
55     merge_strategy.lookup(dps, lookup_invocation) do |data_provider|
56       data_provider.unchecked_key_lookup(key, lookup_invocation, merge_strategy)
57     end
58   end
59 end

Protected Instance Methods

assert_config_version(config) click to toggle source

Assert that the given config version is accepted by this data provider.

@param config [HieraConfig] the configuration to check @return [HieraConfig] the argument @raise [Puppet::DataBinding::LookupError] if the configuration version is unacceptable

   # File lib/puppet/pops/lookup/configured_data_provider.rb
68 def assert_config_version(config)
69   config
70 end
configuration_path(lookup_invocation) click to toggle source
   # File lib/puppet/pops/lookup/configured_data_provider.rb
82 def configuration_path(lookup_invocation)
83   provider_root(lookup_invocation) + HieraConfig::CONFIG_FILE_NAME
84 end
provider_root(lookup_invocation) click to toggle source

Return the root of the configured entity

@param lookup_invocation [Invocation] The current lookup invocation @return [Pathname] Path to root of the module @raise [Puppet::DataBinding::LookupError] if the given module is can not be found

   # File lib/puppet/pops/lookup/configured_data_provider.rb
78 def provider_root(lookup_invocation)
79   raise NotImplementedError, "#{self.class.name} must implement method '#provider_root'"
80 end

Private Instance Methods

data_providers(lookup_invocation) click to toggle source
   # File lib/puppet/pops/lookup/configured_data_provider.rb
88 def data_providers(lookup_invocation)
89   config(lookup_invocation).configured_data_providers(lookup_invocation, self)
90 end