On Wednesday, May 9, 2012 at 2:21 PM, Philip Brown wrote:
>
> ookay.. lots of questions, so you get lots of answers :)
>
I figured it would save us both time if none of my questions are helpful. :)
>
> I need a top level validate, not one under a newparam(). I need to ensure
> that multiple params are defined, rather than just some of them.
>
> I'm confirming/denying function calling, with big obnoxious lines such as
> Puppet.debug(" #### function called here")
>
> 1. if I define it in the "type" file, as
> validate do
> unless self[:fmri] and self[:property] and self[:value]
> raise ArgumentError,
> "svcprop must have fmri and property and value"
> end
> end
>
> it works... BUT.. I want to allow multiple providers, and let them pick which
> arguments are required
>
> 2. If I have a type-file definition. that invokes provider.validate, and
> then in the provider file,
>
I'm not sure you mean when you say "type-file definition". Could you clarify?
If you can/are willing to share, it would help to be able to see your
type/provider code.
Here's a gist with a minimal implementation of this functionality, which
hopefully will make it clear where your code differs (and if it really doesn't
differ, we have a truly fascinating mystery on our hands!):
https://gist.github.com/be5e8c6822d5ec34e598
> def validate
> Puppet.debug(" #### Called")
> end
>
>
> It gets called fine.
> (What is the difference between "def validate", and "validate do", btw?! )
>
`validate do` is basically just a convention to do something like `validate if
respond_to? :validate`. It defines a validation block, which is then used
implicitly by Puppet as part of applying the catalog. It could also have been
implemented by having Puppet call any given "validate" method, if one is
provided. I suppose the reasoning was that this way seems less like magic and
more like an obvious part of the type API; I'm not entirely sure.
>
> 3. If I have no type-file definition. but just one in the provider file,
> similar to above,
> it doesnt get called.
>
>
> I've seen another type (file.rb), call
>
> provider.validate if provider.respond_to?(:validate)
>
>
> but I dont see its providers doing anything beyond
>
> "def validate
> ..."
>
> So, I'm baffled.
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/uJqNViZ_QZcJ.
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> To unsubscribe from this group, send email to
> [email protected]
> (mailto:[email protected]).
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
--
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.