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
12 def initialize(config = nil)
13   @config = config.nil? ? nil : assert_config_version(config)
14 end

Public Instance Methods

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

Needed to assign generated version 4 config @deprecated

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

@return [Pathname] the path to the configuration

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

@return [String] the name of this provider

   # File lib/puppet/pops/lookup/configured_data_provider.rb
32 def name
33   n = "#{place} "
34   n << '"' << module_name << '" ' unless module_name.nil?
35   n << 'Data Provider'
36   n << " (#{@config.name})" unless @config.nil?
37   n
38 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
48 def unchecked_key_lookup(key, lookup_invocation, merge)
49   lookup_invocation.with(:data_provider, self) do
50     merge_strategy = MergeStrategy.strategy(merge)
51     dps = data_providers(lookup_invocation)
52     if dps.empty?
53       lookup_invocation.report_not_found(key)
54       throw :no_such_key
55     end
56     merge_strategy.lookup(dps, lookup_invocation) do |data_provider|
57       data_provider.unchecked_key_lookup(key, lookup_invocation, merge_strategy)
58     end
59   end
60 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
69 def assert_config_version(config)
70   config
71 end
configuration_path(lookup_invocation) click to toggle source
   # File lib/puppet/pops/lookup/configured_data_provider.rb
83 def configuration_path(lookup_invocation)
84   provider_root(lookup_invocation) + HieraConfig::CONFIG_FILE_NAME
85 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
79 def provider_root(lookup_invocation)
80   raise NotImplementedError, "#{self.class.name} must implement method '#provider_root'"
81 end

Private Instance Methods

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