summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:54:01 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:54:01 -0700
commit13339a0a0fccd8e3516ef8f4946b90f648a8907a (patch)
treeee1e1d2c70edcbb91729dc01395c024231d0fad6 /lib
parentd3b0f2ce30e4a8cbcbdd0c7128f4ae710a189e83 (diff)
downloadchef-13339a0a0fccd8e3516ef8f4946b90f648a8907a.tar.gz
suppress cookbook self-dependencies and warnlcg/warn-cb-self-dep
cookbooks with self-deps: name 'foo' depends 'foo' are useless and can waste cycles in the depsolver (particularly in the non-solution case), and likely limit the possible choices of depsolvers that we could pick at some point to replace gecode. filtering out the self-dep here will prevent the chef server depsolver from seeing the self-dep and needing to do the work to strip it. also warn the user so that they can remove the self-dep. in the future this will be a hard error. foodcritic also has a rule about removing these.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/cookbook/metadata.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 4f12275a82..01a98fda39 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -286,9 +286,13 @@ class Chef
# === Returns
# versions<Array>:: Returns the list of versions for the platform
def depends(cookbook, *version_args)
- version = new_args_format(:depends, cookbook, version_args)
- constraint = validate_version_constraint(:depends, cookbook, version)
- @dependencies[cookbook] = constraint.to_s
+ if cookbook == name
+ Chef::Log.warn "Ignoring self-dependency in cookbook #{name}, please remove it (in the future this will be fatal)."
+ else
+ version = new_args_format(:depends, cookbook, version_args)
+ constraint = validate_version_constraint(:depends, cookbook, version)
+ @dependencies[cookbook] = constraint.to_s
+ end
@dependencies[cookbook]
end