Sha256: 1944d4ce0518e192dd8f23e1d5314f792fceadc9ef23648ae9171b0165a6303c

Contents?: true

Size: 1.63 KB

Versions: 24

Compression:

Stored size: 1.63 KB

Contents

require 'hiera/puppet_function'

# Returns a merged hash of matches from throughout the hierarchy. In cases where two or
# more hashes share keys, the hierarchy  order determines which key/value pair will be
#  used in the returned hash, with the pair in the highest priority data source winning.
#
#  The function can be called in one of three ways:
#  1. Using 1 to 3 arguments where the arguments are:
#     'key'      [String] Required
#           The key to lookup.
#     'default`  [Any] Optional
#           A value to return when there's no match for `key`. Optional
#     `override` [Any] Optional
#           An argument in the third position, providing a data source
#           to consult for matching values, even if it would not ordinarily be
#           part of the matched hierarchy. If Hiera doesn't find a matching key
#           in the named override data source, it will continue to search through the
#           rest of the hierarchy.
#
#  2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
#     provide the default value. The block is called with one parameter (the key) and
#     should return the value.
#
#  3. Like #1 but with all arguments passed in an array.
#  `hiera_hash` expects that all values returned will be hashes. If any of the values
#  found in the data sources are strings or arrays, puppet will raise a type mismatch error.
#
#  More thorough examples of `hiera_hash` are available at:
#  <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
Puppet::Functions.create_function(:hiera_hash, Hiera::PuppetFunction) do
  init_dispatch

  def merge_type
    :hash
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
puppet-3.8.7 lib/puppet/functions/hiera_hash.rb
puppet-3.8.7-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.7-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.6 lib/puppet/functions/hiera_hash.rb
puppet-3.8.6-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.6-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.5 lib/puppet/functions/hiera_hash.rb
puppet-3.8.5-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.5-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.4 lib/puppet/functions/hiera_hash.rb
puppet-3.8.4-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.4-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.3 lib/puppet/functions/hiera_hash.rb
puppet-3.8.3-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.3-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.2 lib/puppet/functions/hiera_hash.rb
puppet-3.8.2-x86-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.2-x64-mingw32 lib/puppet/functions/hiera_hash.rb
puppet-3.8.1 lib/puppet/functions/hiera_hash.rb
puppet-3.8.1-x86-mingw32 lib/puppet/functions/hiera_hash.rb