On May 4, 2012, at 2:19 PM, Philip Brown wrote:
> 
> 
> On Friday, May 4, 2012 1:42:35 PM UTC-7, Chris Price wrote:
> I'm not an expert on the topic, but my understanding is that you can't create 
> a type without well-defined property/parameter names.  Or, to put it a 
> different way, there is currently no officially sanctioned means by which to 
> support dynamic property/parameter names for a type or a provider.

You are correct that resource types need well-defined names.  We've explored 
alternatives, but it's hard to have a model without defining it specifically 
somewhere.

There are some weird things you can do with defined resources that obscure this 
problem sometimes, but… I can't recommend even figuring out what they are, as I 
have a scar there in my brain from doing so at one point.

> One way that you could work around it is to define a property with a name 
> like "options", whose value would be a hash.  Then there are no restrictions 
> on your hash key names.
> 
> There is some discussion around this topic on the following tickets:
> 
> http://projects.puppetlabs.com/issues/4113
> http://projects.puppetlabs.com/issues/12843
> 
> 
> Thanks for the reply.
> 
> It looks like I'll just have to hack around things by forcing checks in 
> exists?, along the lines of
>     if ! defined?(@resource[:property])
>       raise ArgumentError, "sysprop requires 'property' to be defined"
> 
> 
> Except that... that doesnt seem to be working as-is. Guess I need to use a 
> different conditional.

defined? probably doesn't work very well when checking hash values.  I 
recommend 'nil?' or something similar:

@resource[:property].nil?

-- 
Luke Kanies | http://about.me/lak | http://puppetlabs.com/ | +1-615-594-8199

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to