diff options
author | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2019-12-20 14:16:29 +0530 |
---|---|---|
committer | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2019-12-20 14:16:29 +0530 |
commit | e57e97eb4c72a4a7213eecce8fbb15ce74159848 (patch) | |
tree | 741c06b2d234cefb975efbe65c67b52444868591 /lib/chef/knife | |
parent | e78d3e46ec1c449e48435755811fa47f8ea1e0c9 (diff) | |
download | chef-e57e97eb4c72a4a7213eecce8fbb15ce74159848.tar.gz |
Added client side validation to validate presence of metadata files and validate name field
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 0243b0cf12..c8c9067800 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -99,8 +99,16 @@ class Chef cookbooks = [] cookbooks_to_upload.each do |cookbook_name, cookbook| + raise Chef::Exceptions::MetadataNotFound.new(cookbook.root_paths[0], cookbook_name) unless cookbook.has_metadata_file? + + if cookbook.metadata.name.nil? + message = "Cookbook loaded at path [#{cookbook.root_paths[0]}] has invalid metadata: #{cookbook.metadata.errors.join("; ")}" + raise Chef::Exceptions::MetadataNotValid, message + end + cookbooks << cookbook end + if cookbooks.empty? cookbook_path = config[:cookbook_path].respond_to?(:join) ? config[:cookbook_path].join(", ") : config[:cookbook_path] ui.warn("Could not find any cookbooks in your cookbook path: #{cookbook_path}. Use --cookbook-path to specify the desired path.") @@ -164,7 +172,6 @@ class Chef unless version_constraints_to_update.empty? update_version_constraints(version_constraints_to_update) if config[:environment] end - ensure tmp_cl.unlink! end |