Closed Sharpie closed 7 years ago
So here's what I'm finding. If you try and do rule => undef
or rule => []
, Puppet ends up ignoring this input at all. For the first level, the type has to take the input and hand off to the provider correctly. I started with this:
newproperty(:rule, :array_matching => :all) do
desc 'Match conditions for this group'
require 'pry'; binding.pry
end
So what I found is that if you specify rule => []
, pry
doesn't even fire. Meaning Puppet isn't considering there is an input to work with (basically an undef). If you specify rule => ''
, it does fire. This something to work with.
So on the provider level, if you input rule => ''
, it mostly works. The API wants { rule => nil }
in order to remove all rules. Working with nil
inside of the provider's methods doesn't seem like the right way to go. Puppet often doesn't consider nil
as a value that matters so setters don't fire. I can swap this at the end durin the actual HTTP call.
def update_group(data)
data = Hash[data.map { |k,v| v == [''] ? [k,nil] : [k,v] }]
...
This is kind of unknown to Puppet. It thinks it's dealing with ['']
as the value and reports as such. Last, updating the getter to report the nil
value from the API as ['']
so it is idempotent.
def rule
@property_hash[:rule].nil? ? [''] : @property_hash[:rule]
end
Tried applying the following:
But no changes were made.