From 9e5764641bff1e074cb463259b3ec321af76373e Mon Sep 17 00:00:00 2001 From: Timo Goebel Date: Mon, 13 Mar 2017 14:06:33 +0100 Subject: [PATCH] fixes #17572 - module works with master compile --- lib/puppet/provider/katello_ssl_tool.rb | 4 ++-- lib/puppet/provider/privkey/katello_ssl_tool.rb | 7 ++++--- lib/puppet/type/certs_common.rb | 17 ++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/puppet/provider/katello_ssl_tool.rb b/lib/puppet/provider/katello_ssl_tool.rb index 0eddd6a2..ee689cfa 100644 --- a/lib/puppet/provider/katello_ssl_tool.rb +++ b/lib/puppet/provider/katello_ssl_tool.rb @@ -156,7 +156,7 @@ def self.build_path(file_name = '') def ca_details return @ca_details if defined? @ca_details - if ca_resource = @resource[:ca] + if ca_resource = resource.catalog.resource(@resource[:ca].to_s) name = ca_resource.to_hash[:name] @ca_details = Puppet::Provider::KatelloSslTool::Cert.details(name) else @@ -207,7 +207,7 @@ def mode def cert_details return @cert_details if defined? @cert_details - if cert_resource = @resource[:key_pair] + if cert_resource = resource.catalog.resource(@resource[:key_pair].to_s) name = cert_resource.to_hash[:name] @cert_details = Puppet::Provider::KatelloSslTool::Cert.details(name) else diff --git a/lib/puppet/provider/privkey/katello_ssl_tool.rb b/lib/puppet/provider/privkey/katello_ssl_tool.rb index 2ed08cd9..02dd0c67 100644 --- a/lib/puppet/provider/privkey/katello_ssl_tool.rb +++ b/lib/puppet/provider/privkey/katello_ssl_tool.rb @@ -22,10 +22,11 @@ def expected_content end def source_path - if @resource[:key_pair].type == 'Cert' + key_pair = resource.catalog.resource(@resource[:key_pair].to_s) + if key_pair.type.to_s == 'cert' cert_details[:privkey] - elsif @resource[:key_pair].type == 'Ca' - Puppet::Type::Ca::ProviderKatello_ssl_tool.privkey(@resource[:key_pair].to_hash[:name]) + elsif key_pair.type.to_s == 'ca' + Puppet::Type::Ca::ProviderKatello_ssl_tool.privkey(key_pair.to_hash[:name]) end end diff --git a/lib/puppet/type/certs_common.rb b/lib/puppet/type/certs_common.rb index 0730462f..9c76bbf4 100644 --- a/lib/puppet/type/certs_common.rb +++ b/lib/puppet/type/certs_common.rb @@ -42,15 +42,16 @@ module Certs newparam(:ca) do validate do |value| - if value && !value.is_a?(Puppet::Resource) || value.resource_type.name != :ca - raise ArgumentError, "Expected Ca resource" + ca_resource = resource.catalog.resource(value.to_s) + if ca_resource && ca_resource.class.to_s != 'Puppet::Type::Ca' + raise ArgumentError, "Expected Ca resource, got #{ca_resource.class} #{ca_resource.inspect}" end end end autorequire(:ca) do if @parameters.has_key?(:ca) - @parameters[:ca].value.to_hash[:name] + catalog.resource(@parameters[:ca].value.to_s).to_hash[:name] end end end @@ -67,15 +68,17 @@ module Certs newparam(:key_pair) do validate do |value| - unless value.is_a?(Puppet::Resource) && (value.resource_type.name == :ca || value.resource_type.name == :cert) - raise ArgumentError, "Expected Ca or Cert resource" + param_resource = resource.catalog.resource(value.to_s) + if param_resource && !['Puppet::Type::Ca', 'Puppet::Type::Cert'].include?(param_resource.class.to_s) + raise ArgumentError, "Expected Ca or Cert resource, got #{param_resource.class} #{param_resource.inspect}" end end end define_method(:autorequire_cert) do |type| - if @parameters.has_key?(:key_pair) && @parameters[:key_pair].value.type == type - @parameters[:key_pair].value.to_hash[:name] + if @parameters.has_key?(:key_pair) + key_pair = catalog.resource(@parameters[:key_pair].value.to_s) + key_pair.to_hash[:name] if key_pair && key_pair.type == type end end