lib/puppet/resource_api.rb in puppet-resource_api-1.4.0 vs lib/puppet/resource_api.rb in puppet-resource_api-1.4.1
- old
+ new
@@ -76,10 +76,11 @@
define_method(:initialize) do |attributes|
# $stderr.puts "A: #{attributes.inspect}"
if attributes.is_a? Puppet::Resource
@title = attributes.title
+ @catalog = attributes.catalog
attributes = attributes.to_hash
else
@ral_find_absent = true
end
# $stderr.puts "B: #{attributes.inspect}"
@@ -109,11 +110,11 @@
end
define_method(:to_resource_shim) do |resource|
resource_hash = Hash[resource.keys.map { |k| [k, resource[k]] }]
resource_hash[:title] = resource.title
- ResourceShim.new(resource_hash, type_definition.name, type_definition.namevars, type_definition.attributes)
+ ResourceShim.new(resource_hash, type_definition.name, type_definition.namevars, type_definition.attributes, catalog)
end
validate do
# enforce mandatory attributes
@missing_attrs = []
@@ -341,10 +342,11 @@
define_method(:flush) do
raise_missing_attrs
# puts 'flush'
# skip puppet's injected metaparams
- target_state = Hash[@parameters.reject { |k, _v| [:loglevel, :noop, :provider].include? k }.map { |k, v| [k, v.rs_value] }]
+ actual_params = @parameters.select { |k, _v| type_definition.attributes.key? k }
+ target_state = Hash[actual_params.map { |k, v| [k, v.rs_value] }]
target_state = my_provider.canonicalize(context, [target_state]).first if type_definition.feature?('canonicalize')
retrieve unless @rapi_current_state
return if @rapi_current_state == target_state