puppetlabs / puppetlabs-node_manager

Create and manage PE node groups as resources.
Apache License 2.0
10 stars 22 forks source link

Added logic for cancelling unwanted classes/variables for issue #11 #14

Closed WhatsARanjit closed 7 years ago

WhatsARanjit commented 7 years ago

The classes and variables attributes are additive. Meaning if you have a current resource like:

node_group { 'test':
  classes   => { klass{} => {}},
  variables => { 'key' => 'value' },
}

...and we write a node_group definition like:

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.