diff options
author | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2019-10-22 14:12:22 +0530 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-01-22 22:42:27 -0800 |
commit | 93e025efbf1b3fadf873da5cee1a6e6ed13afd5a (patch) | |
tree | 10a98667ee8d51360ad8590f1f5930b5c52cffee /lib/chef | |
parent | 69560f82984aaf08602c8449d5992609a121d796 (diff) | |
download | chef-93e025efbf1b3fadf873da5cee1a6e6ed13afd5a.tar.gz |
Deprecated the load method in cookbook_version_loader and added deprecation warning for it. Updated code to raise error if cookbook repo has cookbook directory without cookbook files, this is to make sure user should fix their cookbook repo and remove any garbage from cookbook repository and then do bulk upload.
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 28 | ||||
-rw-r--r-- | lib/chef/cookbook_uploader.rb | 15 | ||||
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 3 |
3 files changed, 12 insertions, 34 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 8d4c3208fd..fe3652bbdf 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -65,14 +65,6 @@ class Chef # Load the cookbook. Raises an error if the cookbook_path given to the # constructor doesn't point to a valid cookbook. def load! - # file_paths_map = load - - # if empty? - # raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook" - # end - - # file_paths_map - metadata # force lazy evaluation to occur # re-raise any exception that occurred when reading the metadata @@ -83,8 +75,9 @@ class Chef remove_ignored_files if empty? - Chef::Log.warn "Found a directory #{cookbook_name} in the cookbook path, but it contains no cookbook files. skipping." + raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook" end + cookbook_settings end @@ -92,23 +85,10 @@ class Chef # directory as the cookbook_path. This behavior is provided for # compatibility, it is recommended to use #load! instead. def load - Chef::Log.warn "This method is deprecated. Use load! instead" - # metadata # force lazy evaluation to occur - - # re-raise any exception that occurred when reading the metadata - # raise_metadata_error! - - # load_all_files - - # remove_ignored_files - - # if empty? - # Chef::Log.warn "Found a directory #{cookbook_name} in the cookbook path, but it contains no cookbook files. skipping." - # end - # cookbook_settings + Chef::Log.warn "load method is deprecated. Use load! instead" end - alias :load_cookbooks :load + alias :load_cookbooks :load! def cookbook_version return nil if empty? diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb index 91c7e49c5e..042100bab7 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -139,14 +139,13 @@ class Chef def validate_cookbooks cookbooks.each do |cb| - unless cb.nil? - syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cb.root_dir) - Chef::Log.info("Validating ruby files") - exit(1) unless syntax_checker.validate_ruby_files - Chef::Log.info("Validating templates") - exit(1) unless syntax_checker.validate_templates - Chef::Log.info("Syntax OK") - end + next if cb.nil? + syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cb.root_dir) + Chef::Log.info("Validating ruby files") + exit(1) unless syntax_checker.validate_ruby_files + Chef::Log.info("Validating templates") + exit(1) unless syntax_checker.validate_templates + Chef::Log.info("Syntax OK") end end diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 7605366718..7bda2815e7 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -167,7 +167,6 @@ class Chef exit 1 end end - unless version_constraints_to_update.empty? update_version_constraints(version_constraints_to_update) if config[:environment] end @@ -192,7 +191,7 @@ class Chef end end rescue Exceptions::CookbookNotFoundInRepo => e - ui.error("Could not find cookbook #{cookbook_name} in your cookbook path, skipping it") + ui.error(e.message) Log.debug(e) end end |