diff options
author | Tim Smith <tsmith@chef.io> | 2021-09-16 18:41:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-16 18:41:39 -0700 |
commit | 56c1a28ccee823e434239626a8fdcb4788478f1c (patch) | |
tree | bb4646d80b28ca5241b85da6f6f7768d85e28612 | |
parent | ef0584b4c8fdc418438b40f93fbdea1de05a66d4 (diff) | |
parent | 6027cbcb95e4ee91138e00ba6d794d69f4265186 (diff) | |
download | chef-56c1a28ccee823e434239626a8fdcb4788478f1c.tar.gz |
Merge pull request #12050 from chef/policyfile_compat_16
Deprecate the old policyfile compat mode
-rw-r--r-- | lib/chef/deprecated.rb | 4 | ||||
-rw-r--r-- | lib/chef/policy_builder/policyfile.rb | 5 | ||||
-rw-r--r-- | spec/unit/policy_builder/policyfile_spec.rb | 12 |
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb index 7f5838d273..c5466be92e 100644 --- a/lib/chef/deprecated.rb +++ b/lib/chef/deprecated.rb @@ -251,6 +251,10 @@ class Chef target 32 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 35282bf915..4419d1dc59 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -148,6 +148,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 6be0da8f4d..b430ea16e6 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -206,7 +206,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 @@ -214,6 +214,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 @@ -339,6 +341,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]"] @@ -806,6 +812,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" |