do some trickery as arguments from puppet are passed as an array

This commit is contained in:
mh 2010-12-16 17:33:04 +01:00
parent 584cee7236
commit fa3d9e1654

View file

@ -5,7 +5,7 @@ Puppet::Parser::Functions::newfunction(:ssh_keygen, :type => :rvalue, :doc =>
the directory hierarchy if required. the directory hierarchy if required.
It accepts only fully qualified paths, everything else will fail.") do |args| It accepts only fully qualified paths, everything else will fail.") do |args|
raise Puppet::ParseError, "Wrong number of arguments" unless args.to_a.length == 1 raise Puppet::ParseError, "Wrong number of arguments" unless args.to_a.length == 1
private_key_path = args private_key_path = args.to_a[0]
raise Puppet::ParseError, "Only fully qualified paths are accepted (#{private_key_path})" unless private_key_path =~ /^\/.+/ raise Puppet::ParseError, "Only fully qualified paths are accepted (#{private_key_path})" unless private_key_path =~ /^\/.+/
public_key_path = "#{private_key_path}.pub" public_key_path = "#{private_key_path}.pub"
raise Puppet::ParseError, "Either only the private or only the public key exists" if File.exists?(private_key_path) ^ File.exists?(public_key_path) raise Puppet::ParseError, "Either only the private or only the public key exists" if File.exists?(private_key_path) ^ File.exists?(public_key_path)