diff options
author | Giacomo Bagnoli <gbagnoli@gmail.com> | 2016-09-20 15:15:08 +0100 |
---|---|---|
committer | Giacomo Bagnoli <gbagnoli@gmail.com> | 2016-09-21 15:58:07 +0100 |
commit | 39774946fbbd8b1f7d3267df3fcb7369ad5cac6d (patch) | |
tree | b675e2919c982bc8a9fe0e50ef15d4a9a55c5e16 /lib/chef/node/attribute.rb | |
parent | ce694677fdc808143a28457dc44d56e97930b9ec (diff) | |
download | chef-39774946fbbd8b1f7d3267df3fcb7369ad5cac6d.tar.gz |
Convert attributes defined as literal arrays
VividMash, unlike Mash, does not recursively convert values inside
arrays, just the array itself.
As such, hashes inside arrays are not converted to *Mash, introducing
a behaviour that differs from Chef 11, e.g.
having this attr defined
node['foo'] = [ { 'attr' => 'value' } ]
in Chef 11 `node[:foo][0][:attr]` returns `'value'` while in Chef 12 it
returns `nil`
This commit fixes VividMash so arrays are recursively converted and the
behaviour restored.
Plus, immutablize merge_all result, so to be sure that hashes contained
in Arrays are properly immutablized as well, so not existing attributes
are not automatically vivified (thus returning an empty VividMash
instead of nil)
This problem was first reported in chef/chef#2871.
Signed-off-by: Giacomo Bagnoli <gbagnoli@gmail.com>
Diffstat (limited to 'lib/chef/node/attribute.rb')
-rw-r--r-- | lib/chef/node/attribute.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 95b3b09f7e..a4a07275c0 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -452,9 +452,7 @@ class Chef # def merged_attributes(*path) - # immutablize( - merge_all(path) - # ) + immutablize(merge_all(path)) end def combined_override(*path) |