Issue #8707 has been updated by Ken Barber.

I'd be wary because users may have already put in work-arounds in their
content.

This behaviour change is probably better done in a release jump like 2.8 as
people would be more likely to read release notes and test their content
properly.
On Apr 20, 2012 5:08 PM, <[email protected]> wrote:

>   Issue #8707 has been updated by Andrew Parker.
>
>
> The lookupvar() method in the master branch for Telly currently does
> return nil instead of :undefined, should this be backported to 2.7?
> ------------------------------
> Bug #8707: Scope.lookupvar() returns undef perhaps should return 
> nil<https://projects.puppetlabs.com/issues/8707#change-61053>
>
>    - Author: Karl Pietri
>    - Status: Accepted
>    - Priority: Normal
>    - Assignee:
>    - Category: templates
>    - Target version: 2.7.x
>    - Affected Puppet version: 2.7.10
>    - Keywords:
>    - Branch:
>
> When in a erb template in puppet if you use scope.lookupvar() with a
> variable that doesn’t exist you get a return value of the label undefined
> (:undefined) this breaks being able to do this:
>
> <% if scope.lookupvar("::ipadress_eth2") %>i have an eth2 <% end %>
>
> Examples:
>
>     err(inline_template('testing truth: <% if 
> scope.lookupvar("::ipaddress_eth1") %>has ip: <%= 
> scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))
>     err(inline_template('testing undefined str: <% if 
> scope.lookupvar("::ipaddress_eth1")!="undefined" %>has ip: <%= 
> scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))
>     err(inline_template('testing undefined label: <% if 
> scope.lookupvar("::ipaddress_eth1")!=:undefined %>has ip: <%= 
> scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))
>
> output:
>
> Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
> (Scope(Class[Shared::Sshd])) testing truth: has ip: undefined
> Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
> (Scope(Class[Shared::Sshd])) testing undefined str: has ip: undefined
> Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
> (Scope(Class[Shared::Sshd])) testing undefined label: has no ip
>
> Perhaps the function should return nil instead of :undefined to prevent
> confusion
>
> -karl
>
> PS not sure if this is a bug or a feature request
> ------------------------------
>
> 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
>
----------------------------------------
Bug #8707: Scope.lookupvar() returns undef perhaps should return nil
https://projects.puppetlabs.com/issues/8707#change-61058

Author: Karl Pietri
Status: Accepted
Priority: Normal
Assignee: 
Category: templates
Target version: 2.7.x
Affected Puppet version: 2.7.10
Keywords: 
Branch: 


When in a erb template in puppet if you use scope.lookupvar() with a variable 
that doesn't exist you get a return value of the label undefined (:undefined) 
this breaks being able to do this:

    <% if scope.lookupvar("::ipadress_eth2") %>i have an eth2 <% end %>

Examples:
        err(inline_template('testing truth: <% if 
scope.lookupvar("::ipaddress_eth1") %>has ip: <%= 
scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))
        err(inline_template('testing undefined str: <% if 
scope.lookupvar("::ipaddress_eth1")!="undefined" %>has ip: <%= 
scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))
        err(inline_template('testing undefined label: <% if 
scope.lookupvar("::ipaddress_eth1")!=:undefined %>has ip: <%= 
scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>'))

output:
    Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
(Scope(Class[Shared::Sshd])) testing truth: has ip: undefined
    Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
(Scope(Class[Shared::Sshd])) testing undefined str: has ip: undefined
    Jul 29 12:10:29 monitor1.example.com puppet-master[533]: 
(Scope(Class[Shared::Sshd])) testing undefined label: has no ip

Perhaps the function should return nil instead of :undefined to prevent 
confusion

-karl

PS not sure if this is a bug or a feature request


-- 
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 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-bugs?hl=en.

Reply via email to