Closed WhatsARanjit closed 7 years ago
The classes and variables attributes are additive. Meaning if you have a current resource like:
classes
variables
node_group { 'test': classes => { klass{} => {}}, variables => { 'key' => 'value' }, }
...and we write a node_group definition like:
node_group
node_group { 'test': classes => {}, variables => {}, }
..the intended result is to remove all classes and variables. However, the actual result is to append new items to existing items. So:
{ klass{} => {}} + {} { 'key' => 'value' } + {}
...and so the result is nothing is actually changed. In order to remove items, you actually have to submit:
{ klass{} => {}} + { klass => null } { 'key' => 'value' } + { 'key' => null }
Sending a null signals the API to remove the item. This PR adds a add_nulls() method which diffs current-state/desired-state to add null values to things that should be removed.
null
add_nulls()
The
classes
andvariables
attributes are additive. Meaning if you have a current resource like:...and we write a
node_group
definition like:..the intended result is to remove all classes and variables. However, the actual result is to append new items to existing items. So:
...and so the result is nothing is actually changed. In order to remove items, you actually have to submit:
Sending a
null
signals the API to remove the item. This PR adds aadd_nulls()
method which diffs current-state/desired-state to addnull
values to things that should be removed.