summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2019-10-28 10:03:14 -0700
committerGitHub <noreply@github.com>2019-10-28 10:03:14 -0700
commit8063d78dfcea5dd829d0ea845abf747e4fcd2660 (patch)
tree5ec4fa7107d95762982fcbf4555cf2515ad20fe8
parentf62d1fc80eb857ffabdbb5cabe166bbdbe840561 (diff)
parent53a48e49f0a8e474a287698dc93ce9727358b467 (diff)
downloadchef-8063d78dfcea5dd829d0ea845abf747e4fcd2660.tar.gz
[Data-collector] Add cookbooks attribute to run_end_message (#8893)
[Data-collector] Add cookbooks attribute to run_end_message
-rw-r--r--lib/chef/data_collector/run_end_message.rb1
-rw-r--r--spec/unit/data_collector_spec.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/data_collector/run_end_message.rb b/lib/chef/data_collector/run_end_message.rb
index 341df5694f..762058bfdb 100644
--- a/lib/chef/data_collector/run_end_message.rb
+++ b/lib/chef/data_collector/run_end_message.rb
@@ -57,6 +57,7 @@ class Chef
"resources" => all_action_records(action_collection),
"run_id" => run_status&.run_id,
"run_list" => node&.run_list&.for_json || [],
+ "cookbooks" => ( node && node["cookbooks"] ) || {},
"policy_name" => node&.policy_name,
"policy_group" => node&.policy_group,
"start_time" => run_status.start_time.utc.iso8601,
diff --git a/spec/unit/data_collector_spec.rb b/spec/unit/data_collector_spec.rb
index 2f33a429fc..5eeeec1498 100644
--- a/spec/unit/data_collector_spec.rb
+++ b/spec/unit/data_collector_spec.rb
@@ -46,6 +46,8 @@ describe Chef::DataCollector do
let(:run_list) { node.run_list }
+ let(:cookbooks) { node.fetch("cookbooks", {}) }
+
let(:run_id) { run_status.run_id }
let(:expansion) { Chef::RunList::RunListExpansion.new("_default", run_list.run_list_items) }
@@ -211,6 +213,11 @@ describe Chef::DataCollector do
send_run_failed_or_completed_event
end
+ it "has a cookbooks" do
+ expect_converge_message("cookbooks" => cookbooks)
+ send_run_failed_or_completed_event
+ end
+
it "has a source" do
expect_converge_message("source" => "chef_client")
send_run_failed_or_completed_event