source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 1.1 KB
Line 
1module Puppet::Parser::Functions
2
3 newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args|
4 Validate that all passed values are hash data structures. Abort catalog
5 compilation if any value fails this check.
6
7 The following values will pass:
8
9 $my_hash = { 'one' => 'two' }
10 validate_hash($my_hash)
11
12 The following values will fail, causing compilation to abort:
13
14 validate_hash(true)
15 validate_hash('some_string')
16 $undefined = undef
17 validate_hash($undefined)
18
19 ENDHEREDOC
20
21 function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.'])
22
23 unless args.length > 0 then
24 raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
25 end
26
27 args.each do |arg|
28 unless arg.is_a?(Hash)
29 raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}")
30 end
31 end
32
33 end
34
35end
Note: See TracBrowser for help on using the repository browser.