diff options
author | Tim Smith <tsmith@chef.io> | 2018-09-18 21:41:56 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-09-18 21:41:56 -0700 |
commit | a0856a1f257797b6f8f07406cd1277aeb0caef8b (patch) | |
tree | d8e4f55f17363ca72611b1082c3dc738756c7732 | |
parent | c2d168e31a33c37299e25b24fa57851b97340a65 (diff) | |
download | chef-inspector.tar.gz |
Blacklist certain resources from being returned in the resource inspectorinspector
lwrp_base and unresolved_subscribes shouldn't be there as well as all the subclassed resources from user
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource_inspector.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb index 7363aad2a6..c4aa35e268 100644 --- a/lib/chef/resource_inspector.rb +++ b/lib/chef/resource_inspector.rb @@ -78,6 +78,17 @@ module ResourceInspector end end + # is a resource blacklisted for the inspector tool? + # + # @private + # @param resource [Class] + # @return [TrueClass, FalseClass] true if the resource is a bogus resource or derived from Chef::Resource::User since we don't want each user resource documented + def self.blacklisted_resource?(resource) + return true if %w{ Chef::Resource::LWRPBase Chef::Resource::UnresolvedSubscribes }.include?(resource.name) + return true if resource < Chef::Resource::User + false + end + # If we're given no resources, dump all of Chef's built ins # otherwise, if we have a path then extract all the resources from the cookbook # or else do a list of built in resources @@ -86,7 +97,7 @@ module ResourceInspector # @return [String] JSON formatting of all resources def self.inspect(arguments = [], complete: false) output = if arguments.empty? - ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) } + ObjectSpace.each_object(Class).select { |k| (k < Chef::Resource && !blacklisted_resource?(k)) }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) } else arguments.each_with_object({}) do |arg, acc| if File.directory?(arg) |