Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / keys.rb
1 #
2 # keys.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:keys, :type => :rvalue, :doc => <<-DOC
6     Returns the keys of a hash as an array.
7
8     Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
9     will be used instead of this function.
10     DOC
11              ) do |arguments|
12
13     raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
14
15     hash = arguments[0]
16
17     unless hash.is_a?(Hash)
18       raise(Puppet::ParseError, 'keys(): Requires hash to work with')
19     end
20
21     result = hash.keys
22
23     return result
24   end
25 end
26
27 # vim: set ts=2 sw=2 et :