Class: Puppet::Pops::Lookup::V3LookupKeyFunctionProvider Private

Inherits:
LookupKeyFunctionProvider show all
Defined in:
lib/puppet/pops/lookup/lookup_key_function_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.

Constant Summary collapse

TAG =

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

'v3_lookup_key'

Instance Attribute Summary

Attributes inherited from FunctionProvider

#function_name, #locations, #parent_data_provider

Instance Method Summary collapse

Methods inherited from LookupKeyFunctionProvider

#invoke_with_location, #label

Methods inherited from FunctionProvider

#create_function_context, #full_name, #function_context, #module_name, #name, #options, #to_s, trusted_return_type, #value_is_validated?

Methods included from DataProvider

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

Constructor Details

#initialize(name, parent_data_provider, function_name, options, locations) ⇒ V3LookupKeyFunctionProvider

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 V3LookupKeyFunctionProvider.



71
72
73
74
# File 'lib/puppet/pops/lookup/lookup_key_function_provider.rb', line 71

def initialize(name, parent_data_provider, function_name, options, locations)
  @datadir = options.delete(HieraConfig::KEY_DATADIR)
  super
end

Instance Method Details

#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.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/puppet/pops/lookup/lookup_key_function_provider.rb', line 76

def unchecked_key_lookup(key, lookup_invocation, merge)
  extra_paths = lookup_invocation.hiera_v3_location_overrides
  if extra_paths.nil? || extra_paths.empty?
    super
  else
    # Extra paths provided. Must be resolved and placed in front of known paths
    paths = parent_data_provider.config(lookup_invocation).resolve_paths(@datadir, extra_paths, lookup_invocation, false, ".#{@name}")
    all_locations = paths + locations
    root_key = key.root_key
    lookup_invocation.with(:data_provider, self) do
      MergeStrategy.strategy(merge).lookup(all_locations, lookup_invocation) do |location|
        invoke_with_location(lookup_invocation, location, root_key, merge)
      end
    end
  end
end