puppet-neutron/lib/puppet/functions/convert_cert_to_string.rb
Tobias Urdin 37bb654424 Use puppet4 functions-api
Change-Id: Id124ec4c598c7b6bcb7c8134d75825fd01d938d2
2018-12-18 10:32:11 +00:00

20 lines
494 B
Ruby

Puppet::Functions.create_function(:convert_cert_to_string) do
dispatch :convert_cert_to_string do
param 'String', :cert_file
end
def convert_cert_to_string(cert_file)
unless File.file?(cert_file)
raise Puppet::ParseError, "Certificate file not found: #{cert_file}"
end
text=File.readlines(cert_file)
cert_string = ''
text.each do |line|
unless line.include? '-----'
cert_string += line.strip
end
end
return cert_string
end
end