Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #17572 - module works with master compile #127

Merged
merged 1 commit into from
Mar 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/provider/katello_ssl_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/puppet/provider/privkey/katello_ssl_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 10 additions & 7 deletions lib/puppet/type/certs_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down