diff options
author | Tim Smith <tsmith@chef.io> | 2020-05-18 12:07:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 12:07:10 -0700 |
commit | ff13b5c2e4d7781a118bee4377d926e1f8bb46b0 (patch) | |
tree | 57b2d1cfcc323632bb23ca75df59237f991ed2dc | |
parent | ff02c248813616f322879eb437f2c398017c0201 (diff) | |
parent | 9601876d934b37f6948e2a26f4ad59dc1a9d09db (diff) | |
download | chef-ff13b5c2e4d7781a118bee4377d926e1f8bb46b0.tar.gz |
Merge pull request #9882 from chef/fix_resource_inspector
Fix failures inspecting a single cookbook
-rw-r--r-- | lib/chef/resource_inspector.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb index bc96ffd4a3..a12b06fcb2 100644 --- a/lib/chef/resource_inspector.rb +++ b/lib/chef/resource_inspector.rb @@ -69,8 +69,8 @@ module ResourceInspector dir, name = File.split(path) Chef::Cookbook::FileVendor.fetch_from_disk(path) loader = Chef::CookbookLoader.new(dir) - cookbooks = loader.load_cookbooks - resources = cookbooks[name].files_for(:resources) + cookbook = loader.load_cookbook(name) + resources = cookbook.files_for(:resources) resources.each_with_object({}) do |r, res| pth = r["full_path"] @@ -83,13 +83,14 @@ module ResourceInspector # otherwise, if we have a path then extract all the resources from the cookbook # or else do a list of built in resources # + # @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class # @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) } else - arguments.each_with_object({}) do |arg, acc| + Array(arguments).each_with_object({}) do |arg, acc| if File.directory?(arg) extract_cookbook(arg, complete).each { |k, v| acc[k] = v } else |