diff options
author | danielsdeleo <dan@chef.io> | 2016-10-28 14:38:14 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2016-11-02 08:06:38 -0700 |
commit | 3ca1eb9726f73bb6be8fca41cb7de7134529000f (patch) | |
tree | 58b94c66fe0a2c699686001af16afb6986005f56 /lib/chef/data_collector.rb | |
parent | c9739381fc9956b7e94b9687c14be6742afb3b93 (diff) | |
download | chef-3ca1eb9726f73bb6be8fca41cb7de7134529000f.tar.gz |
Extract data collector http config to a private method
Signed-off-by: Daniel DeLeo <dan@chef.io>
Diffstat (limited to 'lib/chef/data_collector.rb')
-rw-r--r-- | lib/chef/data_collector.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb index 4365497bab..f544a4b044 100644 --- a/lib/chef/data_collector.rb +++ b/lib/chef/data_collector.rb @@ -113,12 +113,7 @@ class Chef @deprecations = Set.new @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 + @http = setup_http_client end # see EventDispatch::Base#run_started @@ -285,6 +280,19 @@ class Chef private + # Selects the type of HTTP client to use based on whether we are using + # token-based or signed header authentication. Token authentication is + # intended to be used primarily for Chef Solo in which case no signing + # key will be available (in which case `Chef::ServerAPI.new()` would + # raise an exception. + def setup_http_client + if data_collector_token.nil? + Chef::ServerAPI.new(data_collector_server_url) + else + Chef::HTTP::SimpleJSON.new(data_collector_server_url) + end + end + # # Yields to the passed-in block (which is expected to be some interaction # with the DataCollector endpoint). If some communication failure occurs, |