Skip to content

Commit

Permalink
Check if file exists before loading with loadyaml. If not, return nil
Browse files Browse the repository at this point in the history
  • Loading branch information
amateo committed Sep 2, 2014
1 parent 9e8127b commit b9560df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/puppet/parser/functions/loadyaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b9560df

Please sign in to comment.