summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-07-13 20:33:05 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2021-07-13 20:35:25 -0700
commit3604bdc3417832fbe50b39824064964b309ac933 (patch)
tree81a1d8eb5150dbe282ec9d94eac79f2dbd9a0167
parent04db98a247020adde3a004fb7a4d0e3dfa97213f (diff)
downloadchef-3604bdc3417832fbe50b39824064964b309ac933.tar.gz
Deprecate the old policyfile compat mode
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/policy_builder/policyfile.rb5
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb12
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index ec2082d159..16fdf49256 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -133,6 +133,11 @@ class Chef
# consume_external_attrs may add items to the run_list. Save the
# expanded run_list, which we will pass to the server later to
# determine which versions of cookbooks to use.
+
+ unless Chef::Config[:policy_document_native_api]
+ Chef.deprecated(:policyfile_compat_mode, "The chef-server 11 policyfile compat mode is deprecated, please set policy_document_native_api to true in your config")
+ end
+
node.reset_defaults_and_overrides
node.consume_external_attrs(ohai_data, json_attribs)
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index 0f19bca070..63dc300f2a 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -202,7 +202,7 @@ describe Chef::PolicyBuilder::Policyfile do
end
before do
- Chef::Config[:policy_document_native_api] = false
+ Chef::Config[:policy_document_native_api] = true
Chef::Config[:deployment_group] = "example-policy-stage"
allow(policy_builder).to receive(:api_service).and_return(api_service)
end
@@ -210,6 +210,8 @@ describe Chef::PolicyBuilder::Policyfile do
describe "when using compatibility mode (policy_document_native_api == false)" do
before do
+ Chef::Config[:policy_document_native_api] = false
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
Chef::Config[:deployment_group] = "example-policy-stage"
end
@@ -335,6 +337,10 @@ describe Chef::PolicyBuilder::Policyfile do
end
describe "validating the Policyfile.lock" do
+ before do
+ Chef::Config[:policy_group] = "policy-stage"
+ Chef::Config[:policy_name] = "example"
+ end
it "errors if the policyfile json contains any non-recipe items" do
parsed_policyfile_json["run_list"] = ["role[foo]"]
@@ -815,6 +821,10 @@ describe Chef::PolicyBuilder::Policyfile do
context "when using compatibility mode (policy_document_native_api == false)" do
let(:cookbook1_url) { "cookbooks/example1/#{example1_xyz_version}" }
let(:cookbook2_url) { "cookbooks/example2/#{example2_xyz_version}" }
+ before do
+ Chef::Config[:policy_document_native_api] = false
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ end
context "when the cookbooks don't exist on the server" do
include_examples "fetching cookbooks when they don't exist"