class Puppet::Pops::Lookup::GlobalDataProvider
@api private
Public Instance Methods
place()
click to toggle source
# File lib/puppet/pops/lookup/global_data_provider.rb 8 def place 9 'Global' 10 end
unchecked_key_lookup(key, lookup_invocation, merge)
click to toggle source
Calls superclass method
Puppet::Pops::Lookup::ConfiguredDataProvider#unchecked_key_lookup
# File lib/puppet/pops/lookup/global_data_provider.rb 12 def unchecked_key_lookup(key, lookup_invocation, merge) 13 config = config(lookup_invocation) 14 if(config.version == 3) 15 # Hiera version 3 needs access to special scope variables 16 scope = lookup_invocation.scope 17 unless scope.is_a?(Hiera::Scope) 18 return lookup_invocation.with_scope(Hiera::Scope.new(scope)) do |hiera_invocation| 19 20 # Confine to global scope unless an environment data provider has been defined (same as for hiera_xxx functions) 21 adapter = lookup_invocation.lookup_adapter 22 hiera_invocation.set_global_only unless adapter.global_only? || adapter.has_environment_data_provider?(lookup_invocation) 23 hiera_invocation.lookup(key, lookup_invocation.module_name) { unchecked_key_lookup(key , hiera_invocation, merge) } 24 end 25 end 26 27 merge = MergeStrategy.strategy(merge) 28 unless config.merge_strategy.is_a?(DefaultMergeStrategy) 29 if lookup_invocation.hiera_xxx_call? && merge.is_a?(HashMergeStrategy) 30 # Merge strategy defined in the hiera config only applies when the call stems from a hiera_hash call. 31 merge = config.merge_strategy 32 lookup_invocation.set_hiera_v3_merge_behavior 33 end 34 end 35 36 value = super(key, lookup_invocation, merge) 37 if lookup_invocation.hiera_xxx_call? 38 if merge.is_a?(HashMergeStrategy) || merge.is_a?(DeepMergeStrategy) 39 # hiera_hash calls should error when found values are not hashes 40 Types::TypeAsserter.assert_instance_of('value', Types::PHashType::DEFAULT, value) 41 end 42 if !key.segments.nil? && (merge.is_a?(HashMergeStrategy) || merge.is_a?(UniqueMergeStrategy)) 43 strategy = merge.is_a?(HashMergeStrategy) ? 'hash' : 'array' 44 45 # Fail with old familiar message from Hiera 3 46 raise Puppet::DataBinding::LookupError, "Resolution type :#{strategy} is illegal when accessing values using dotted keys. Offending key was '#{key}'" 47 end 48 end 49 value 50 else 51 super 52 end 53 end
Protected Instance Methods
assert_config_version(config)
click to toggle source
# File lib/puppet/pops/lookup/global_data_provider.rb 57 def assert_config_version(config) 58 config.fail(Issues::HIERA_UNSUPPORTED_VERSION_IN_GLOBAL) if config.version == 4 59 config 60 end
configuration_path(lookup_invocation)
click to toggle source
# File lib/puppet/pops/lookup/global_data_provider.rb 70 def configuration_path(lookup_invocation) 71 lookup_invocation.global_hiera_config_path 72 end
provider_root(lookup_invocation)
click to toggle source
Return the root of the environment
@param lookup_invocation [Invocation] The current lookup invocation @return [Pathname] Path to the parent of the hiera configuration file
# File lib/puppet/pops/lookup/global_data_provider.rb 66 def provider_root(lookup_invocation) 67 configuration_path(lookup_invocation).parent 68 end