Issue #3300 has been updated by Nigel Kersten.
Status changed from Needs Decision to Rejected
There's a reasonably simple workaround here:
<pre>
define foo ($val) {
if $val != '' {
$bar = [ 'val1', 'val2', $val ]
} else {
$bar = [ 'val1', 'val2' ]
}
}
</pre>
I'm rejecting this request to append to variables in scope without a stronger
use case for it.
----------------------------------------
Feature #3300: appending to variables already defined in this scope
https://projects.puppetlabs.com/issues/3300
Author: Xavier Delaruelle
Status: Rejected
Priority: Normal
Assignee: Nigel Kersten
Category: parser
Target version:
Affected Puppet version: 0.25.4
Keywords:
Branch:
Hello,
As mentioned in the doc, it is possible since 0.24.6 to append to variables
already defined in a different scope. But when appending to a variable already
defined in the scope, like in the following example:
<pre>
define foo ($val) {
$bar = [ 'val1', 'val2' ]
if $val != '' {
$bar += [ $val ]
}
}
</pre>
puppet returns the following error:
<pre>
Cannot append, variable bar is defined in this scope at /tmp/test.pp:8 on node
host
</pre>
Appending to variables already defined in the scope could be useful when we
want to adapt the behavior of a class or a define depending of variable values.
--
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.