summaryrefslogtreecommitdiff
path: root/lib/chef/resource_reporter.rb
diff options
context:
space:
mode:
authorjamesc <james@opscode.com>2013-07-09 17:54:25 -0700
committerdanielsdeleo <dan@opscode.com>2013-07-10 16:24:31 -0700
commit1c3783bc793115858c4b401aeb9ee3cd16be27d3 (patch)
tree1619ef14764f391340920560dc693fbcfe4ce1d2 /lib/chef/resource_reporter.rb
parent532ed5d95c244a81d5b6eda67ea3e3ba3ada1f57 (diff)
downloadchef-1c3783bc793115858c4b401aeb9ee3cd16be27d3.tar.gz
OC-8641 - new_resource.cookbook_version is nil for some resources
Since the existing tests mocked out Resource#cookbook_version it missed the case where if Resource#cookbook_name is nil then cookbook_version would also be nil. Added guard logic around setting the cookbook_name, cookbook_version in resource_reporter.rb to protect against the case where cookbook_name is nil.
Diffstat (limited to 'lib/chef/resource_reporter.rb')
-rw-r--r--lib/chef/resource_reporter.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index 44e8a068db..33d5d2da6a 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -64,8 +64,14 @@ class Chef
else
#as_hash["result"] = "failed"
end
- as_hash["cookbook_name"] = new_resource.cookbook_name
- as_hash["cookbook_version"] = new_resource.cookbook_version.version
+ if new_resource.cookbook_name
+ as_hash["cookbook_name"] = new_resource.cookbook_name
+ as_hash["cookbook_version"] = new_resource.cookbook_version.version
+ else
+ as_hash["cookbook_name"] = ""
+ as_hash["cookbook_version"] = "0.0.0"
+ end
+
as_hash
end