summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasu1105 <vasundhara.jagdale@msystechnologies.com>2019-10-21 17:49:07 +0530
committerVasu1105 <vasundhara.jagdale@msystechnologies.com>2020-01-22 10:50:37 +0530
commit03257148dd5228049084258f0c4d926f9c5d28ee (patch)
treec8bbf001276193925b2f62bd30ad1bac2ac32593
parent67a19dfb20c787a84a905859f3e6e76faa106bab (diff)
downloadchef-03257148dd5228049084258f0c4d926f9c5d28ee.tar.gz
MSYS-1142 Fixed nil class error and added check to not call upload for the blank cookbooks. Fixes #9010
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
-rw-r--r--lib/chef/cookbook_loader.rb2
-rw-r--r--lib/chef/cookbook_uploader.rb14
-rw-r--r--lib/chef/knife/cookbook_upload.rb1
3 files changed, 9 insertions, 8 deletions
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb
index bdb436e899..5d4ec71d80 100644
--- a/lib/chef/cookbook_loader.rb
+++ b/lib/chef/cookbook_loader.rb
@@ -99,7 +99,7 @@ class Chef
cookbook_version = loader.cookbook_version
cookbooks_by_name[cookbook_name] = cookbook_version
- metadata[cookbook_name] = cookbook_version.metadata
+ metadata[cookbook_name] = cookbook_version.metadata unless cookbook_version.nil?
cookbook_version
end
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index ffc4040194..91c7e49c5e 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -139,12 +139,14 @@ class Chef
def validate_cookbooks
cookbooks.each do |cb|
- syntax_checker = Chef::Cookbook::SyntaxCheck.new(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")
+ 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
end
end
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index c8c9067800..7605366718 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -124,7 +124,6 @@ class Chef
cookbooks_for_upload << cookbook
version_constraints_to_update[cookbook_name] = cookbook.version
end
-
if config[:all]
if cookbooks_for_upload.any?
begin