On Sunday, October 4, 2015 at 5:03:17 PM UTC-5, Danny Roberts wrote: > > I am writing my first custom type/provider for a Puppet module. I can > correctly check for, create & destroy an instance of a resource as well as > update attributes. The existing implementation of the provider is here: > https://github.com/kemra102/puppet-githubapi/blob/master/lib/puppet/provider/github_repo/default.rb > > However if I set an attribute to something other than it's default value > at the time of creation it is ignored. Specifically in the linked code if I > set 'has_wiki' to false it is ignored. > > I realise I'm missing something in my code but I cannot find any clear > reference on what it is exactly. This realisation also made me realise that > collecting all the possible attributes is a potential issue. > > So I guess I have 2 questions right now; > > 1. How do I pass any specified attributes to the create method? > 2. Is there an easy way to collect these attributes? >
You're already pulling some attributes out of the resource hash (name, apikey). That is where you will find the assigned values of all the resource's properties and parameters. What prevents you using it for any other properties you need? Alternatively, you should be able to use the resource's should() method to obtain the target value for any property. It is unfortunate that so many of the details of provider development are poorly documented, and especially that this situation has continued for so long. At least the documentation for the other side (the type) is better. As it stands, I suggest you grab one or two up-to-date modules that provide custom types, and study how they do things. John -- 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 puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/97eb8ec8-dc0c-49bf-9bde-d2a10357fe47%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.