Issue #17206 has been updated by Andrew Parker.
The `defaultto {}` is a little confusing. It actually isn't puppet's fault in
that case, but is a trick of ruby. The suffix of `{}` is interpreted as a block
passed to `defaultto` which has no body and so the value of the block is `nil`.
To properly do a default of an empty hash you'll need to do `defaultto({})`.
The issue with `defaultto false` is a little different. This looks to be caused
by
<https://github.com/puppetlabs/puppet/blob/74fbd0a1d99b7c4bcc666643b61209ebcef47f16/lib/puppet/type.rb#L816>
where the `false` value ends up short circuiting the check.
----------------------------------------
Bug #17206: parameter defaults of false and {} does not work
https://projects.puppetlabs.com/issues/17206#change-97411
* Author: R.I. Pienaar
* Status: Investigating
* Priority: Normal
* Assignee: Andrew Parker
* Category:
* Target version:
* Affected Puppet version: 3.0.1
* Keywords:
* Branch:
----------------------------------------
In a type I have:
<pre>
newparam(:arguments) do
desc "The arguments to send to the action"
defaultto {}
end
</pre>
If I do not set the property and check in my provider the value would be nil
instead of {}. If instead of defaulting to {} I default to [] then the correct
empty array gets to the provider.
Similarly defaulting to false ends up being a nil.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.