diff options
author | Thom May <thom@may.lt> | 2017-04-11 17:53:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-11 17:53:01 +0100 |
commit | 3fc0e33d5051426139a51548e4fc4204cf8545db (patch) | |
tree | 488a4554ecf682a868663c8beaa6307d25f48817 /lib/chef | |
parent | 888daa11b289f1643d5bb159733005433cdad31a (diff) | |
parent | 31d599580d4e3bd655d0cc18e33073ecef921d1c (diff) | |
download | chef-3fc0e33d5051426139a51548e4fc4204cf8545db.tar.gz |
Merge pull request #6045 from coderanger/segment-oops
Fix for Chef 13 upload reversion.
Diffstat (limited to 'lib/chef')
-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" }) |