Method: Hiera::PuppetFunction#lookup

Defined in:
lib/hiera/puppet_function.rb

#lookup(scope, key, default, has_default, override, &default_block) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/hiera/puppet_function.rb', line 63

def lookup(scope, key, default, has_default, override, &default_block)
  unless Puppet[:strict] == :off
    # TRANSLATORS 'lookup' is a puppet function and should not be translated
    message = _("The function '%{class_name}' is deprecated in favor of using 'lookup'.") % { class_name: self.class.name }
    message += ' ' + _("See https://puppet.com/docs/puppet/%{minor_version}/deprecated_language.html") %
                     { minor_version: Puppet.minor_version }
    Puppet.warn_once('deprecations', self.class.name, message)
  end
  lookup_invocation = Puppet::Pops::Lookup::Invocation.new(scope, {}, {})
  adapter = lookup_invocation.lookup_adapter
  lookup_invocation.set_hiera_xxx_call
  lookup_invocation.set_global_only unless adapter.global_only? || adapter.has_environment_data_provider?(lookup_invocation)
  lookup_invocation.set_hiera_v3_location_overrides(override) unless override.nil? || override.is_a?(Array) && override.empty?
  Puppet::Pops::Lookup.lookup(key, nil, default, has_default, merge_type, lookup_invocation, &default_block)
end