On 2015-15-05 24:59, Joshua hoblitt wrote:
> As I'm slowly updating my modules' testing boilerplate for puppet 4.x,
> I've run into a couple cases of breakage that I'm unsure if they are
> intentional changes in semantics or regressions.
>
> When introspecting on a resource and the param is undefined, an empty
> string is now being returned instead of my good friend `undef`.
>
> I understand that '' is the same type of the param in this case but it
> seems like a step backwards to have to go back to [the early days of]
> comparing everything to '' instead of undef.
>
> ```
> $user_home = getparam(User[$user], 'home')
>
> $home = $user_home ? {
> '' => "/home/${user}", # puppet 4.0
> undef => "/home/${user}", # puppet 3.7
> default => $user_home,
> }
> ```
>
> It appears that classes are no longer a first class resource.
There is a chain of things happening here. First User[$user] is
evaluated, it is an instance of a resource type - and it gets translated
to a Resource internally (with type and title). This is then given to
the getparam function. If it does not find a value it returns an empty
string
(
https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/getparam.rb#L34)
An empty string is truthy in 4.x and not the same as undef. The function
should be updated (it should not have returned an empty string in the
3.x version, and it should return nil in 4.x).
There is cleanup of stdlib under way.
>
> ```
> Class['port389::admin::ssl']{ notify =>
> Class['port389::admin::service'] }
> ```
>
> ```
> Evaluation Error: Resource Override can only operate on
> resources, got: Class[port389::admin::ssl]-Type at
> /home/jhoblitt/github/puppet-port389/spec/fixtures/modules/port389/manifests/admin/ssl.pp:8:3
> on node
leo.tuc.noao.edu
> ```
>
That change is intentional. While classes behave as resources for some
operations it is not true for all. It happened to work for forming
relationships, but not for other things. Using the lazy evaluating
relationship expressions is much better (i.e. -> or ~> as Eric Dalén
pointed out).
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/