duritong / puppet-trocla

puppet integration for trocla
11 stars 18 forks source link

trocla_get render #23

Closed fe80 closed 6 years ago

fe80 commented 6 years ago

Hi,

We can't get cert or key only with x509 format, as like https://github.com/duritong/trocla/issues/42

I fix with:

diff --git a/lib/puppet/parser/functions/trocla_get.rb b/lib/puppet/parser/functions/trocla_get.rb
index fb5cd5a..c7596bf 100644
--- a/lib/puppet/parser/functions/trocla_get.rb
+++ b/lib/puppet/parser/functions/trocla_get.rb
@@ -29,8 +29,9 @@ the return value will be undef if the key & format pair is not found.
     end
     require File.dirname(__FILE__) + '/../../util/trocla_helper'
     args[1] ||= 'plain'
-    raise_error = args[2].nil? ? true : args[2]
-    if (answer=Puppet::Util::TroclaHelper.trocla(:get_password,false,[args[0],args[1]])).nil? && raise_error
+    options = args[2] || {}
+    raise_error = args[3].nil? ? true : args[3]
+    if (answer=Puppet::Util::TroclaHelper.trocla(:get_password,true,[args[0],args[1],options])).nil? && raise_error
       raise(Puppet::ParseError, "No password for key,format #{args[0..1].flatten.inspect} found!")
     end
     answer.nil? ? :undef : answer

Options order have change with this fix (raise_error is on args[3])

Do you want I fork and create a merge request ?

duritong commented 6 years ago

Yes, Please make a PR, thank you!