summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-16 18:06:56 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-16 18:06:56 -0800
commita028bda72981a9b58427054d51d69a58b45badc2 (patch)
tree465b056f28d0a4e10df5f6831f67db90615b3ad8 /lib/chef
parentdc9d29eab395c909c3b5a528eeb26fe9ab8e74c8 (diff)
parentb01b75fd0ea20be903b1bcfe7608e2b307bc1f44 (diff)
downloadchef-a028bda72981a9b58427054d51d69a58b45badc2.tar.gz
Merge pull request #4574 from chef/lcg/cookbook-shadow-deprecation
Extend cookbook shadowing deprecation warnings more broadly
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/cookbook_loader.rb20
-rw-r--r--lib/chef/knife/cookbook_upload.rb4
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb
index 9bab6f01ce..9367936c32 100644
--- a/lib/chef/cookbook_loader.rb
+++ b/lib/chef/cookbook_loader.rb
@@ -66,7 +66,17 @@ class Chef
merged_cookbook_paths
end
- def load_cookbooks
+ def warn_about_cookbook_shadowing
+ unless merged_cookbooks.empty?
+ Chef::Log.deprecation "The cookbook(s): #{merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path. " +
+ "A composite version has been compiled. This has been deprecated since 0.10.4, in Chef 13 this behavior will be REMOVED."
+ end
+ end
+
+ # Will be removed when cookbook shadowing is removed, do NOT create new consumers of this API.
+ #
+ # @api private
+ def load_cookbooks_without_shadow_warning
preload_cookbooks
@loaders_by_name.each do |cookbook_name, _loaders|
load_cookbook(cookbook_name)
@@ -74,9 +84,17 @@ class Chef
@cookbooks_by_name
end
+ def load_cookbooks
+ ret = load_cookbooks_without_shadow_warning
+ warn_about_cookbook_shadowing
+ ret
+ end
+
def load_cookbook(cookbook_name)
preload_cookbooks
+ return @cookbooks_by_name[cookbook_name] if @cookbooks_by_name.has_key?(cookbook_name)
+
return nil unless @loaders_by_name.key?(cookbook_name.to_s)
cookbook_loaders_for(cookbook_name).each do |loader|
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index cd16358e3f..72f7d9d2d9 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -103,7 +103,7 @@ class Chef
@server_side_cookbooks = Chef::CookbookVersion.list_all_versions
justify_width = @server_side_cookbooks.map { |name| name.size }.max.to_i + 2
if config[:all]
- cookbook_repo.load_cookbooks
+ cookbook_repo.load_cookbooks_without_shadow_warning
cookbooks_for_upload = []
cookbook_repo.each do |cookbook_name, cookbook|
cookbooks_for_upload << cookbook
@@ -164,7 +164,7 @@ class Chef
def cookbooks_to_upload
@cookbooks_to_upload ||=
if config[:all]
- cookbook_repo.load_cookbooks
+ cookbook_repo.load_cookbooks_without_shadow_warning
else
upload_set = {}
@name_args.each do |cookbook_name|