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.3 KB
|
Line | |
---|
1 | module Puppet::Parser::Functions
|
---|
2 |
|
---|
3 | newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args|
|
---|
4 | Validate that all passed values are either true or false. Abort catalog
|
---|
5 | compilation if any value fails this check.
|
---|
6 |
|
---|
7 | The following values will pass:
|
---|
8 |
|
---|
9 | $iamtrue = true
|
---|
10 | validate_bool(true)
|
---|
11 | validate_bool(true, true, false, $iamtrue)
|
---|
12 |
|
---|
13 | The following values will fail, causing compilation to abort:
|
---|
14 |
|
---|
15 | $some_array = [ true ]
|
---|
16 | validate_bool("false")
|
---|
17 | validate_bool("true")
|
---|
18 | validate_bool($some_array)
|
---|
19 |
|
---|
20 | ENDHEREDOC
|
---|
21 |
|
---|
22 | # The deprecation function was being called twice, as validate_bool calls is_bool. I have removed it from here so it only calls deprecation once within is_bool.
|
---|
23 | # function_deprecation([:validate_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
|
---|
24 |
|
---|
25 | unless args.length > 0 then
|
---|
26 | raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
|
---|
27 | end
|
---|
28 |
|
---|
29 | args.each do |arg|
|
---|
30 | unless function_is_bool([arg])
|
---|
31 | raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}")
|
---|
32 | end
|
---|
33 | end
|
---|
34 |
|
---|
35 | end
|
---|
36 |
|
---|
37 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.