Skip to content

Commit a459e3e

Browse files
committed
Fix for resources that have a parameter named type
According to https://www.puppet.com/docs/puppet/7/lang_reserved.html#parameter-names `type` is perfectly acceptable as the name of a class or defined type parameter. For example https://github.com/voxpupuli/puppet-rsyslog/blob/3e6a94cd92e59c8d4a289b9e1fbb30e227bb48e6/manifests/component/template.pp#L5 Unfortunately, the existing code decided it was looking at a resource, (and not a resource's changed parameters), by looking for a hash key of `type`. This was tripping it up when formatting the report. Specifically, the code would explode here https://github.com/voxpupuli/puppet-catalog_diff/blob/a60fd2d526056feb31122b44823a35e8215f4305/lib/puppet/catalog-diff/formater.rb#L54 with ``` Error: undefined method `sort_by' for nil:NilClass` ``` as the method isn't being fed a resource and the `:parameters` key is missing. In this commit, we check the value of `header` to make sure we're not calling `format.resource_reference` with something that isn't a resource, and instead fall through to the correct `Format hash diffs` code in the `else`. (https://github.com/voxpupuli/puppet-catalog_diff/blob/a60fd2d526056feb31122b44823a35e8215f4305/lib/puppet/face/catalog/diff.rb#L298)
1 parent a60fd2d commit a459e3e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/puppet/face/catalog/diff.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
value.map do |resource_id, resource|
284284
next if resource.nil?
285285

286-
if resource.is_a?(Hash) && resource.key?(:type)
286+
if resource.is_a?(Hash) && resource.key?(:type) && !%i[params_in_old params_in_new].include?(header)
287287
# If we find an actual resource print it out
288288
format.resource_reference(header, resource_id, resource)
289289
elsif resource.is_a?(Array)

0 commit comments

Comments
 (0)