summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-05-21 13:46:42 +0100
committerThom May <thom@may.lt>2015-05-21 13:46:42 +0100
commit605552d20d7dee84484f9d197d11a42c05d0ee1f (patch)
tree23e0eca35095bf51e0cb11d06c3b314d51037041
parente470d561f9338cc99e7c7e6372e03a53f21dd232 (diff)
parentb21bbe7915177d5a6672e56c2bb29104540085c4 (diff)
downloadchef-605552d20d7dee84484f9d197d11a42c05d0ee1f.tar.gz
Merge pull request #3407 from chef/policyfile-native-default
Make native mode the default for policyfiles
-rw-r--r--chef-config/lib/chef-config/config.rb23
-rw-r--r--spec/unit/knife_spec.rb9
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb6
3 files changed, 29 insertions, 9 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 800e8065de..63de8a451f 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -339,16 +339,23 @@ module ChefConfig
# most of our testing scenarios)
default :minimal_ohai, false
- # Policyfile is an experimental feature where a node gets its run list and
- # cookbook version set from a single document on the server instead of
- # expanding the run list and having the server compute the cookbook version
- # set based on environment constraints.
- #
- # Because this feature is experimental, it is not recommended for
- # production use. Developent/release of this feature may not adhere to
- # semver guidelines.
+ # Policyfile is a feature where a node gets its run list and cookbook
+ # version set from a single document on the server instead of expanding the
+ # run list and having the server compute the cookbook version set based on
+ # environment constraints.
default :use_policyfile, false
+ # Policyfiles can be used in a native mode (default) or compatibility mode.
+ # Native mode requires Chef Server 12.1 (it can be enabled via feature flag
+ # on some prior versions). In native mode, policies and associated
+ # cookbooks are accessed via feature-specific APIs. In compat mode,
+ # policies are stored as data bags and cookbooks are stored at the
+ # cookbooks/ endpoint. Compatibility mode can be dangerous on existing Chef
+ # Servers; it's recommended to upgrade your Chef Server rather than use
+ # compatibility mode. Compatibility mode remains available so you can use
+ # policyfiles with servers that don't yet support the native endpoints.
+ default :policy_document_native_api, true
+
# Set these to enable SSL authentication / mutual-authentication
# with the server
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 7aab16ce99..3e8a43eaf5 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -30,11 +30,20 @@ describe Chef::Knife do
let(:knife) { Chef::Knife.new }
+ let(:config_location) { File.expand_path("~/.chef/config.rb") }
+
+ let(:config_loader) do
+ instance_double("WorkstationConfigLoader", load: nil, no_config_found?: false, config_location: config_location)
+ end
+
before(:each) do
Chef::Log.logger = Logger.new(StringIO.new)
Chef::Config[:node_name] = "webmonkey.example.com"
+ allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
+ allow(config_loader).to receive(:explicit_config_file=)
+
# Prevent gratuitous code reloading:
allow(Chef::Knife).to receive(:load_commands)
allow(knife.ui).to receive(:puts)
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index ad7c83b03b..5fa00d8f2b 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -166,13 +166,17 @@ describe Chef::PolicyBuilder::Policyfile do
end
before do
- # TODO: agree on this name and logic.
+ Chef::Config[:policy_document_native_api] = false
Chef::Config[:deployment_group] = "example-policy-stage"
allow(policy_builder).to receive(:http_api).and_return(http_api)
end
describe "when using compatibility mode (policy_document_native_api == false)" do
+ before do
+ Chef::Config[:deployment_group] = "example-policy-stage"
+ end
+
context "when the deployment group cannot be loaded" do
let(:error404) { Net::HTTPServerException.new("404 message", :body) }