Simple refactoring + assign __resource_registry to the current if needed.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-12-30 11:15:28 -08:00
parent 81dfe21a98
commit f0a5ddd4df

View file

@ -170,13 +170,18 @@ module Inspec
# rubocop:enable Lint/NestedMethodDefinition
reg = __resource_registry rescue nil
reg = self.__resource_registry = Inspec::Resource.registry unless reg
# Warn if a resource pack is overwriting a core resource.
# Suppress warning if the resource is an AWS resource, see #3822
if __resource_registry.key?(name) && !name.start_with?("aws_")
if reg.key?(name) && !name.start_with?("aws_")
Inspec::Log.warn("Overwriting resource #{name}. To reference a specific version of #{name} use the resource() method")
end
__resource_registry[name] = cl
end
reg[name] = cl
end # __register
end
module Plugins