On 14/10/2015 22:56, Danny Roberts wrote:
In a custom type/provider I am writing it seems that the provider is not entirely idempotent.

The provider (https://github.com/kemra102/puppet-githubapi/blob/master/lib/puppet/provider/github_repo/default.rb) is calling the Github API (https://developer.github.com/v3/repos/#edit) and amending an attribute that is a boolean on the API side is what is causing the issue.

The API always returns a boolean value as expected however the Puppet provider converts the boolean value provided to a symbol and presumably it is this that is causing the value to always be modified even if for example it is already the value specified in the resource.

Notice: Compiled catalog for iacon.cybertron.local in environment production in 0.06 seconds
FalseClass
{"name"=>"apitest", "has_wiki"=>:false}
Symbol
Notice: /Stage[main]/Main/Github_repo[apitest]/has_wiki: has_wiki changed 'false' to 'false'
Notice: Finished catalog run in 2.51 seconds

In the above I added some cheap and dirty debugging which shows;

FalseClass = This is the value returned by the GitHub API.
{"name"=>"apitest", "has_wiki"=>:false} - The values being sent in the body of the request to the GitHub API.
Symbol - As is probably clear this is the class of the 'has_wiki' value.

Any ideas how to correctly match up these values and not cause an unrequired update?


Excellent analysis, you've almost solved it. https://github.com/kemra102/puppet-githubapi/blob/master/lib/puppet/provider/github_repo/default.rb#L78 returns the value from the API. This has to match what puppet receives from the manifest. Adding '.to_sym' or something similar should fix this.


Cheers, D.

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/5620CE60.4040208%40puppetlabs.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to