diff options
author | danielsdeleo <dan@getchef.com> | 2014-08-07 16:32:02 -0700 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2014-08-12 11:03:10 -0700 |
commit | 2577c6f8f503dd6484ca656c9b3780c52cc6e038 (patch) | |
tree | f6f53cb2ac2d03305c9ca849e30cecb99303b0c9 /lib/chef/cookbook | |
parent | 89427a59886b0724a5a1101dde7ea1a1def1c67a (diff) | |
download | chef-2577c6f8f503dd6484ca656c9b3780c52cc6e038.tar.gz |
Make `name` a required attribute in metadata
Diffstat (limited to 'lib/chef/cookbook')
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 15 | ||||
-rw-r--r-- | lib/chef/cookbook/metadata.rb | 1 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 02bc4fb0db..6c85cdef54 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -147,12 +147,6 @@ class Chef @metadata = Chef::Cookbook::Metadata.new - # Compatibility if metadata is missing the name attribute: - # TODO: Metadata should distinguish between inferred name and actual. - if @metadata.name.nil? - @metadata.name(@inferred_cookbook_name) - end - metadata_filenames.each do |metadata_file| case metadata_file when /\.rb$/ @@ -166,7 +160,6 @@ class Chef end end - @metadata # Rescue errors so that users can upload cookbooks via `knife cookbook @@ -181,6 +174,14 @@ class Chef def raise_metadata_error! raise @metadata_error unless @metadata_error.nil? + # Metadata won't be valid if the cookbook is empty. If the cookbook is + # actually empty, a metadata error here would be misleading, so don't + # raise it (if called by #load!, a different error is raised). + if !empty? && !metadata.valid? + message = "Cookbook loaded at path(s) [#{@cookbook_paths.join(', ')}] has invalid metadata: #{metadata.errors.join('; ')}" + raise Exceptions::MetadataNotValid, message + end + false end def empty? diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index c1fe20e748..3964354d50 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -18,6 +18,7 @@ # limitations under the License. # +require 'chef/exceptions' require 'chef/mash' require 'chef/mixin/from_file' require 'chef/mixin/params_validate' |