diff options
| author | Salim Afiune <afiune@chef.io> | 2016-11-03 18:01:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-03 18:01:56 -0400 |
| commit | 9441dcaa99160bfcd7d8ea3eda7b10597fd70163 (patch) | |
| tree | 5c5136a79b7a4f365e7246a8df9315724f8d465b /chef-config | |
| parent | 4c4b645a233204aa16bbe2177280ec769d20e81d (diff) | |
| parent | 49cc8b15d99216c5fb55b690e8cd22d22e5f359f (diff) | |
| download | chef-9441dcaa99160bfcd7d8ea3eda7b10597fd70163.tar.gz | |
Merge pull request #5511 from chef/allow-tokenless-chef-solo-data-collector
Enable data collector w/o token for solo, but require explicit URL
Diffstat (limited to 'chef-config')
| -rw-r--r-- | chef-config/lib/chef-config/config.rb | 8 | ||||
| -rw-r--r-- | chef-config/spec/unit/config_spec.rb | 22 |
2 files changed, 26 insertions, 4 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 2c1fcf21c0..fb8e19518f 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -857,7 +857,13 @@ module ChefConfig # Full URL to the endpoint that will receive our data. If nil, the # data collector will not run. # Ex: http://my-data-collector.mycompany.com/ingest - default(:server_url) { File.join(config_parent.chef_server_url, "/data-collector") } + default(:server_url) do + if config_parent.solo || config_parent.local_mode + nil + else + File.join(config_parent.chef_server_url, "/data-collector") + end + end # An optional pre-shared token to pass as an HTTP header (x-data-collector-token) # that can be used to determine whether or not the poster of this diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index e6070adb5a..806ab7d4fa 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -1131,9 +1131,25 @@ RSpec.describe ChefConfig::Config do context "when using default settings" do - it "configures the data collector URL as a relative path to the Chef Server URL" do - ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/myorg" - expect(ChefConfig::Config[:data_collector][:server_url]).to eq("https://chef.example/organizations/myorg/data-collector") + context "for Chef Client" do + + it "configures the data collector URL as a relative path to the Chef Server URL" do + ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/myorg" + expect(ChefConfig::Config[:data_collector][:server_url]).to eq("https://chef.example/organizations/myorg/data-collector") + end + + end + + context "for Chef Solo" do + + before do + ChefConfig::Config[:solo] = true + end + + it "sets the data collector server URL to nil" do + ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/myorg" + expect(ChefConfig::Config[:data_collector][:server_url]).to be_nil + end end |
