diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-25 02:02:00 +0100 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-25 02:02:00 +0100 |
commit | 61936fdeaaadb25e83ccb766e6b9ac872527a50d (patch) | |
tree | dac755376a7fcf23ffb4c834a400de36fd938eb7 | |
parent | 4a72b0efde7069f76b142cc2349f4ec60001a50d (diff) | |
download | puppet-stdlib-61936fdeaaadb25e83ccb766e6b9ac872527a50d.tar.gz puppet-stdlib-61936fdeaaadb25e83ccb766e6b9ac872527a50d.tar.bz2 |
Updated error check and reporting. Also we now return empty
string value i.e. "" instead of raising an exception when a
particular fact is not present. We also make use of strinterp()
explicitly to evaluate arguments passed to the function.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r-- | fact.rb | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -44,17 +44,25 @@ partitions define given above. EOS ) do |arguments| - raise(Puppet::ParseError, "Wrong number of arguments " + + raise(Puppet::ParseError, "fact(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 fact = arguments[0] - raise(Puppet::ParseError, 'You must provide fact name') if fact.empty? + raise(Puppet::ParseError, 'fact(): You must provide ' + + 'fact name') if fact.empty? + fact = strinterp(fact) # Evaluate any interpolated variable names ... result = lookupvar(fact) # Get the value of interest from Facter ... if not result or result.empty? - raise(Puppet::ParseError, "Unable to retrieve fact `#{fact}'") + # + # Now this is a funny one ... Puppet does not have a concept of + # returning neither undef nor nil back for use within the Puppet DSL + # and empty string is as closest to actual undef as you we can get + # at this point in time ... + # + result = '' end return result |