Class: Puppet::Pops::Lookup::ConfiguredDataProvider Private

Inherits:
Object
  • Object
show all
Includes:
DataProvider
Defined in:
lib/puppet/pops/lookup/configured_data_provider.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods included from DataProvider

#key_lookup, #key_lookup_in_default, key_type, #lookup, #module_name, register_types, #validate_data_hash, #validate_data_value, #value_is_validated?, value_type

Constructor Details

#initialize(config = nil) ⇒ ConfiguredDataProvider

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ConfiguredDataProvider.

Parameters:

  • config (HieraConfig, nil) (defaults to: nil)

    the configuration



11
12
13
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 11

def initialize(config = nil)
  @config = config.nil? ? nil : assert_config_version(config)
end

Instance Method Details

#config(lookup_invocation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 15

def config(lookup_invocation)
  @config ||= assert_config_version(HieraConfig.create(lookup_invocation, configuration_path(lookup_invocation), self))
end

#config=(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.

Needed to assign generated version 4 config



21
22
23
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 21

def config=(config)
  @config = config
end

#config_pathPathname

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the path to the configuration.

Returns:

  • (Pathname)

    the path to the configuration



26
27
28
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 26

def config_path
  @config.nil? ? nil : @config.config_path
end

#nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the name of this provider.

Returns:

  • (String)

    the name of this provider



31
32
33
34
35
36
37
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 31

def name
  n = "#{place} "
  n << '"' << module_name << '" ' unless module_name.nil?
  n << 'Data Provider'
  n << " (#{@config.name})" unless @config.nil?
  n
end

#unchecked_key_lookup(key, lookup_invocation, merge) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Parameters:

  • key (String)

    The key to lookup

  • lookup_invocation (Invocation)

    The current lookup invocation

  • merge (MergeStrategy, String, Hash{String => Object}, nil)

    Merge strategy, merge strategy name, strategy and options hash, or nil (implies “first found”)

Returns:

  • (Object)

    the found object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/puppet/pops/lookup/configured_data_provider.rb', line 47

def unchecked_key_lookup(key, lookup_invocation, merge)
  lookup_invocation.with(:data_provider, self) do
    merge_strategy = MergeStrategy.strategy(merge)
    dps = data_providers(lookup_invocation)
    if dps.empty?
      lookup_invocation.report_not_found(key)
      throw :no_such_key
    end
    merge_strategy.lookup(dps, lookup_invocation) do |data_provider|
      data_provider.unchecked_key_lookup(key, lookup_invocation, merge_strategy)
    end
  end
end