Sha256: 5e5a5858d8a276d2b6329ba999b4d7aa4848a8118f8e94bd718e3b73ce44c32e

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

#
# module_array.rb
#
module Puppet::Parser::Functions
  newfunction(:module_array, :type => :rvalue, :doc => <<-EOS
This function performs a lookup for a variable value in various locations:
See: module_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, "module_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] : {} )
      
      module_name     = self.source.module_name
      module_var_name = "#{module_name}::#{var_name}"
      
      config = CORL::Config.init(options, [ :param, :module_array ], module_name, {
        :provisioner  => :puppetnode,
        :hiera_scope  => self,
        :puppet_scope => self,
        :search       => 'core::default',
        :search_name  => false,
        :force        => true,
        :merge        => true
      })
      value = CORL::Config.lookup_array(module_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/module_array.rb