Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem introduced in #346 and simplification of create #349

Merged
merged 4 commits into from
May 10, 2015

Conversation

cataphract
Copy link
Contributor

Look at the individual commit messages for more information.

cataphract added 4 commits May 8, 2015 18:19
It was a plain parameter (not property) with no effect. Now it's an
property that actually backs the subscription json key. Its default was
also strange: the symbol :name. Now it's the value of the name property
(I suppose this was the original intention).
Using Puppet::Property::Boolean does not work correctly. It munges the
value to (boolean) true and false. This causes an unfortunate problem.
Once a property is true, it's not possible to change it back to false.
This is because on ResourceHarness::sync_if_needed() the property value
is not even checked to be in sync of if the should value is false:

    if param.should && !param.safe_insync?(current_value)

This should probably read `if !param.should.nil?`. But since it doesn't,
this commit introduces a new superclass for the boolean properties that
normalizes to :true/:false instead. To avoid extra complexity in the
provider, wich has to work with actual booleans, the superclass also
overrides `set` and `retrieve` to shield the provider from having to do
converisons :true/:false => true/false and back.

This creates an additional problem, though. The should value retrieved
in the provider through `resource[:boolean_property]` will still be
:true/:false. Because the `create` methods in providers are littered
with statements such as

    self.<property name> = resource[:<property name>]

the setters in the providers will still be called with :true/:false.
This will be addressed in the next commit.
The new `create` implemented in a module will call
`Property::set(value)` rather than the provider setters directly. This
is to allow `Property::set` to do extra magic before delegating back to
the provider, as is done in `PuppetX::Sensu::BooleanProperty`.
@jamtur01
Copy link
Contributor

jamtur01 commented May 8, 2015

Wow. Nice fix. I'll try to review on the weekend - @jlambert121 ping too.

jamtur01 added a commit that referenced this pull request May 10, 2015
Fix problem introduced in #346 and simplification of create
@jamtur01 jamtur01 merged commit 4081d7a into sensu:master May 10, 2015
@jamtur01
Copy link
Contributor

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants