Skip to content

Commit

Permalink
Workaround problem with deep merge
Browse files Browse the repository at this point in the history
  • Loading branch information
christine_draper committed Jan 21, 2016
1 parent 43db4f3 commit a9cf7c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/chef/knife/topo/node_update_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_node_with_values(node, updates)
def update_attrs(node, attrs)
return false unless attrs
attrs.delete('tags')
original = node.normal.clone
original = Marshal.load(Marshal.dump(node.normal))
node.normal = Chef::Mixin::DeepMerge.merge(node.normal, attrs)
original != node.normal
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chef/knife/topo/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# version
module KnifeTopo
VERSION = '2.0.2'
VERSION = '2.0.3'
end
8 changes: 8 additions & 0 deletions spec/unit/topo_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,13 @@
@cmd.update_node_with_values(node, 'normal' => { 'attr1' => 'val2' })
expect(node['attr1']).to eq('val2')
end

it 'detects and saves change in nested attributes' do
node = Chef::Node.new
node.normal = { 'level1' => { 'level2' => { 'attr1' => 'val1' } } }
expect(node).to receive(:save)
@cmd.do_node_updates(node, 'normal' => { 'level1' =>
{ 'level2' => { 'attr1' => 'val2' } } })
end
end
end

0 comments on commit a9cf7c8

Please sign in to comment.