summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-11-01 17:17:31 +0000
committerGitHub <noreply@github.com>2016-11-01 17:17:31 +0000
commit2fc0990abc65f3ab717887dd7bdfd3517bc2ec0f (patch)
tree96bfbcc0fe1c3d8211c45a8f4b913f3bce434775 /lib
parent8cabbb7a61a49eba48ef20132fdf6ee90f94713c (diff)
parent3a4442b96ba2005a9616e0f3137f651580a06ee7 (diff)
downloadchef-2fc0990abc65f3ab717887dd7bdfd3517bc2ec0f.tar.gz
Merge pull request #5496 from chef/adamleff/deprecations-to-data-collector
Add deprecations to Data Collector competion message
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/data_collector.rb17
-rw-r--r--lib/chef/data_collector/messages.rb3
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index dbb0b3771a..2aad0d74b0 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -23,6 +23,7 @@ require "chef/event_dispatch/base"
require "chef/data_collector/messages"
require "chef/data_collector/resource_report"
require "ostruct"
+require "set"
class Chef
@@ -54,7 +55,7 @@ class Chef
class Reporter < EventDispatch::Base
attr_reader :all_resource_reports, :status, :exception, :error_descriptions,
:expanded_run_list, :run_context, :run_status, :http,
- :current_resource_report, :enabled
+ :current_resource_report, :enabled, :deprecations
def initialize
validate_data_collector_server_url!
@@ -63,6 +64,7 @@ class Chef
@current_resource_loaded = nil
@error_descriptions = {}
@expanded_run_list = {}
+ @deprecations = Set.new
@http = Chef::HTTP.new(data_collector_server_url)
@enabled = true
end
@@ -223,6 +225,12 @@ class Chef
)
end
+ # see EventDispatch::Base#deprecation
+ # Append a received deprecation to the list of deprecations
+ def deprecation(message, location = caller(2..2)[0])
+ add_deprecation(message, location)
+ end
+
private
#
@@ -288,7 +296,8 @@ class Chef
expanded_run_list: expanded_run_list,
resources: all_resource_reports,
status: opts[:status],
- error_descriptions: error_descriptions
+ error_descriptions: error_descriptions,
+ deprecations: deprecations.to_a
).to_json
)
end
@@ -340,6 +349,10 @@ class Chef
@error_descriptions = discription_hash
end
+ def add_deprecation(message, location)
+ @deprecations << { message: message, location: location }
+ end
+
def create_resource_report(new_resource, action, current_resource = nil)
Chef::DataCollector::ResourceReport.new(
new_resource,
diff --git a/lib/chef/data_collector/messages.rb b/lib/chef/data_collector/messages.rb
index 8c2a84b580..e0dfd6cb67 100644
--- a/lib/chef/data_collector/messages.rb
+++ b/lib/chef/data_collector/messages.rb
@@ -66,7 +66,7 @@ class Chef
"entity_uuid" => node_uuid,
"expanded_run_list" => reporter_data[:expanded_run_list],
"id" => run_status.run_id,
- "message_version" => "1.0.0",
+ "message_version" => "1.1.0",
"message_type" => "run_converge",
"node" => run_status.node,
"node_name" => run_status.node.name,
@@ -80,6 +80,7 @@ class Chef
"status" => reporter_data[:status],
"total_resource_count" => reporter_data[:resources].count,
"updated_resource_count" => reporter_data[:resources].select { |r| r.report_data["status"] == "updated" }.count,
+ "deprecations" => reporter_data[:deprecations],
}
message["error"] = {