diff options
Diffstat (limited to 'lib/chef/cookbook/manifest_v0.rb')
-rw-r--r-- | lib/chef/cookbook/manifest_v0.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/chef/cookbook/manifest_v0.rb b/lib/chef/cookbook/manifest_v0.rb index 3e50d86071..fd2d62a6d4 100644 --- a/lib/chef/cookbook/manifest_v0.rb +++ b/lib/chef/cookbook/manifest_v0.rb @@ -27,13 +27,14 @@ class Chef COOKBOOK_SEGMENTS = %w{ resources providers recipes definitions libraries attributes files templates root_files } def self.from_hash(hash) - response = Mash.new + response = Mash.new(hash) response[:all_files] = COOKBOOK_SEGMENTS.inject([]) do |memo, segment| next memo if hash[segment].nil? || hash[segment].empty? hash[segment].each do |file| file["name"] = "#{segment}/#{file["name"]}" unless segment == "root_files" memo << file end + response.delete(segment) memo end response @@ -44,7 +45,7 @@ class Chef result.delete("all_files") files = manifest.by_parent_directory - files.keys.inject(result) do |memo, parent| + files.keys.each_with_object(result) do |parent, memo| if COOKBOOK_SEGMENTS.include?(parent) memo[parent] ||= [] files[parent].each do |file| @@ -53,7 +54,11 @@ class Chef memo[parent] << file end end - memo + end + # Ensure all segments are set to [] if they don't exist. + # See https://github.com/chef/chef/issues/6044 + COOKBOOK_SEGMENTS.each do |segment| + result[segment] ||= [] end result.merge({ "frozen?" => manifest.frozen_version?, "chef_type" => "cookbook_version" }) |