summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-07-14 07:50:56 -0700
committerGitHub <noreply@github.com>2021-07-14 07:50:56 -0700
commit52aea1ab18e552523763d034156b7e15d46cd515 (patch)
tree5c401e17be244a600c84f462516945f01fee5a0a
parent04db98a247020adde3a004fb7a4d0e3dfa97213f (diff)
parent7dbc3fd9888aac4e0b2282294928fb663e67a97e (diff)
downloadchef-52aea1ab18e552523763d034156b7e15d46cd515.tar.gz
Merge pull request #11804 from chef/lcg/policyfile-compat-deprecation2
Deprecate the old policyfile compat mode
-rw-r--r--lib/chef/deprecated.rb4
-rw-r--r--lib/chef/policy_builder/policyfile.rb5
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb12
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 4960e03871..f41b3d5443 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -259,6 +259,10 @@ class Chef
target 34
end
+ class PolicyfileCompatMode < Base
+ target 35
+ end
+
class Generic < Base
def url
"https://docs.chef.io/chef_deprecations_client/"
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"