diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 18 | ||||
-rw-r--r-- | lib/chef/cookbook_loader.rb | 4 | ||||
-rw-r--r-- | lib/chef/cookbook_uploader.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 4 |
4 files changed, 17 insertions, 11 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index f9ec765e47..7e09fae60c 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -65,19 +65,24 @@ 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 + 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? raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook" end - file_paths_map + cookbook_settings end - # Load the cookbook. Does not raise an error if given a non-cookbook - # directory as the cookbook_path. This behavior is provided for - # compatibility, it is recommended to use #load! instead. def load + Chef::Log.warn "load method is deprecated. Use load! instead" metadata # force lazy evaluation to occur # re-raise any exception that occurred when reading the metadata @@ -88,8 +93,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 diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index bdb436e899..f02b07eaaf 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -95,11 +95,11 @@ class Chef loader = cookbook_version_loaders[cookbook_name] - loader.load + loader.load! 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..b9d4bfe5d1 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -139,6 +139,8 @@ class Chef def validate_cookbooks cookbooks.each do |cb| + next if cb.nil? + syntax_checker = Chef::Cookbook::SyntaxCheck.new(cb.root_dir) Chef::Log.info("Validating ruby files") exit(1) unless syntax_checker.validate_ruby_files diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index c8c9067800..7bda2815e7 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 @@ -168,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 @@ -193,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 |