summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2020-01-24 16:09:21 -0800
committerGitHub <noreply@github.com>2020-01-24 16:09:21 -0800
commit6aa9764c249a8090170f8725cf8fe0cc0fbdfaa4 (patch)
tree21f17e7f33406f2d1823e5100c4ead885e2b4225
parentc1b7260011b6ea55c455b9e3ffeb9133c9300b27 (diff)
parenta354ad1c6abd748616e90f6d4a2af435ca0f68a6 (diff)
downloadchef-6aa9764c249a8090170f8725cf8fe0cc0fbdfaa4.tar.gz
switch the load method back to not raising + deprecation (#9274)
switch the load method back to not raising + deprecation
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb4
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb9
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index cf7bff1ff8..2c4fe6db41 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -82,7 +82,7 @@ class Chef
end
def load
- Chef::Log.warn "Chef::Cookbook::CookbookVersionLoader's load method is deprecated. Please use load! instead."
+ Chef.deprecated(:internal_api, "Chef::Cookbook::CookbookVersionLoader's load method is deprecated. Please use load! instead.")
metadata # force lazy evaluation to occur
# re-raise any exception that occurred when reading the metadata
@@ -93,7 +93,7 @@ class Chef
remove_ignored_files
if empty?
- raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook"
+ Chef::Log.warn "Found a directory #{cookbook_name} in the cookbook path, but it contains no cookbook files. skipping."
end
cookbook_settings
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 518ffa7d2d..b1c2a46827 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2014-2018, Chef Software Inc.
+# Copyright:: Copyright 2014-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -124,8 +124,9 @@ describe Chef::Cookbook::CookbookVersionLoader do
expect { cookbook_loader.load! }.to raise_error(Chef::Exceptions::CookbookNotFoundInRepo)
end
- it "gives deprecation warning called with #load and raise error for Cookbook not found" do
- expect { cookbook_loader.load }.to raise_error(Chef::Exceptions::CookbookNotFoundInRepo)
+ it "gives deprecation warning called with #load" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ cookbook_loader.load
end
end
@@ -149,6 +150,7 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
it "gives deprecation warning to us load! when called with #load and raises error" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
expect { cookbook_loader.load }.to raise_error("THIS METADATA HAS A BUG")
end
@@ -181,6 +183,7 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
it "gives deprecation warning to use load! method when called with #load and raises error for invalid metadata" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
expect { cookbook_loader.load }.to raise_error(Chef::Exceptions::MetadataNotValid, error_message)
end