Sha256: 2e7beb3bfb56411d0c98b96cb2260490d9e57f6f3c2780bcd6c461f08dd0d48e

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

#
# global_array.rb
#
# See: global_param.rb
#
module Puppet::Parser::Functions
  newfunction(:global_array, :type => :rvalue, :doc => <<-EOS
This function performs a lookup for a variable value in various locations:
See: global_params()
If no value is found in the defined sources, it returns an empty array ([])
    EOS
) do |args|
    
    value = nil
    CORL.run do
      raise(Puppet::ParseError, "global_array(): Define at least the variable name " +
        "given (#{args.size} for 1)") if args.size < 1
    
      var_name = args[0]
      default  = ( args.size > 1 ? args[1] : [] ) 
      options  = ( args.size > 2 ? args[2] : {} )
    
      config = CORL::Config.init_flat(options, [ :param, :global_array ], {
        :provisioner  => :puppetnode,
        :hiera_scope  => self,
        :puppet_scope => self,
        :search       => 'core::default',
        :force        => true,
        :merge        => true
      })
      value = CORL::Config.lookup_array(var_name, default, config)
    end
    return value
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
corl-0.4.3 lib/puppet/parser/functions/global_array.rb