summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMorgan Haskel <morgan@puppetlabs.com>2015-04-16 10:48:10 -0700
committerMorgan Haskel <morgan@puppetlabs.com>2015-04-16 10:48:10 -0700
commit8a1d1e2f3425ff8fa1d7e74463ec226df2b968c8 (patch)
tree07a0c9a583059d80dcf9c81e287f74c454804377 /lib
parent59b3fb4472c6ceafc6762739e767294054787bd4 (diff)
parentac24e7acc767bce9cc1977f90c798df94292813e (diff)
Merge pull request #314 from amateo/feature/loadyaml_check_file
Check if file exists before loading with loadyaml. If not, return nil
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/loadyaml.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/loadyaml.rb b/lib/puppet/parser/functions/loadyaml.rb
index 10c4005..ca655f6 100644
--- a/lib/puppet/parser/functions/loadyaml.rb
+++ b/lib/puppet/parser/functions/loadyaml.rb
@@ -13,7 +13,12 @@ module Puppet::Parser::Functions
raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
end
- YAML.load_file(args[0])
+ if File.exists?(args[0]) then
+ YAML.load_file(args[0])
+ else
+ warning("Can't load " + args[0] + ". File does not exist!")
+ nil
+ end
end