summaryrefslogtreecommitdiff
path: root/lib/chef/data_collector.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-10-24 17:32:37 -0700
committerdanielsdeleo <dan@chef.io>2016-11-02 08:06:38 -0700
commitb95fce9f28693aa09dd0d37742063027596f6847 (patch)
treee205b2ff4406a618380712320aa0365c10ce4592 /lib/chef/data_collector.rb
parentf9c619bc45e161e1518fd8f534898c4f7665166f (diff)
downloadchef-b95fce9f28693aa09dd0d37742063027596f6847.tar.gz
Allow optional signed header auth for data collector
* When the data collector is enabled but the token is nil, data collector will use signed header auth. * Switch data collector to an HTTP client that includes the JSON content middlewares so both auth methods talk to the `http` object the same way. Signed-off-by: Daniel DeLeo <dan@chef.io>
Diffstat (limited to 'lib/chef/data_collector.rb')
-rw-r--r--lib/chef/data_collector.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index 2aad0d74b0..f07f81c846 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -19,6 +19,8 @@
#
require "uri"
+require "chef/server_api"
+require "chef/http/simple_json"
require "chef/event_dispatch/base"
require "chef/data_collector/messages"
require "chef/data_collector/resource_report"
@@ -65,8 +67,14 @@ class Chef
@error_descriptions = {}
@expanded_run_list = {}
@deprecations = Set.new
- @http = Chef::HTTP.new(data_collector_server_url)
@enabled = true
+
+ @http =
+ if data_collector_token.nil?
+ Chef::ServerAPI.new(data_collector_server_url)
+ else
+ Chef::HTTP::SimpleJSON.new(data_collector_server_url)
+ end
end
# see EventDispatch::Base#run_started
@@ -81,7 +89,7 @@ class Chef
disable_reporter_on_error do
send_to_data_collector(
- Chef::DataCollector::Messages.run_start_message(current_run_status).to_json
+ Chef::DataCollector::Messages.run_start_message(current_run_status)
)
end
end