diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-26 17:01:22 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-28 11:19:49 -0800 |
commit | 7162c001c13d08ac4450dd829da4d501865a9512 (patch) | |
tree | 57dde79ec4ba839ac343569ee2409ed2b3e933ef | |
parent | 292d177a20135d25596c31fdc005ab4a999d4501 (diff) | |
download | chef-7162c001c13d08ac4450dd829da4d501865a9512.tar.gz |
raise on cookbook self-dependency
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | RELEASE_NOTES.md | 6 | ||||
-rw-r--r-- | lib/chef/cookbook/metadata.rb | 4 | ||||
-rw-r--r-- | spec/integration/knife/upload_spec.rb | 14 |
3 files changed, 10 insertions, 14 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 72ffa0d47e..f58c2f0950 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -43,5 +43,9 @@ This change is most likely to only affect internals of tooling like chefspec if ### PolicyFile failback to create non-policyfile nodes on Chef Server < 12.3 has been removed -PolicyFile users on Chef-13 should be using Chef Server 12.3 or higher +PolicyFile users on Chef-13 should be using Chef Server 12.3 or higher. + +### Cookbooks with self dependencies are no longer allowed + +The remediation is removing the self-dependency `depends` line in the metadata. diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index 3f23bc2056..a8ec901e97 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) # Author:: Seth Falcon (<seth@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -306,7 +306,7 @@ class Chef # versions<Array>:: Returns the list of versions for the platform def depends(cookbook, *version_args) if cookbook == name - Chef::Log.warn "Ignoring self-dependency in cookbook #{name}, please remove it (in the future this will be fatal)." + raise "Cookbook depends on itself in cookbook #{name}, please remove the this unnecessary self-dependency" else version = new_args_format(:depends, cookbook, version_args) constraint = validate_version_constraint(:depends, cookbook, version) diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index d372a83a35..dc713d02b3 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software, Inc. +# Copyright:: Copyright 2013-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -178,16 +178,8 @@ EOM file "cookbooks/x/metadata.rb", "name 'x'; version '1.0.0'; depends 'x'" end - it "should warn", chef: "< 13" do - knife("upload /cookbooks").should_succeed( - stdout: "Updated /cookbooks/x\n", - stderr: "WARN: Ignoring self-dependency in cookbook x, please remove it (in the future this will be fatal).\n" - ) - knife("diff --name-status /").should_succeed "" - end - it "should fail in Chef 13", chef: ">= 13" do - knife("upload /cookbooks").should_fail "" - # FIXME: include the error message here + it "should fail in Chef 13" do + expect { knife("upload /cookbooks") }.to raise_error RuntimeError, /Cookbook depends on itself/ end end |