Issue #2491 has been reported by Thomas Bellman.
----------------------------------------
Feature #2491: The regsubst() function should be able to operate on arrays
http://projects.reductivelabs.com/issues/2491
Author: Thomas Bellman
Status: Unreviewed
Priority: Normal
Assigned to: Thomas Bellman
Category: functions
Target version:
Complexity: Easy
Affected version: 0.25.0rc1
Keywords:
It would be nice if one could give an array to regsubst(), and
make it perform the substitution on each element of that array.
One, perhaps non-obvious, use case is to have a definition that
takes an array as parameter, and have it "loop" over that by
giving it as the name parameter to a helper definition, like
this:
define my_define($param, ...)
{
$x = regsubst($param, ".*", "$name//\\&")
my_define_helper {
$x: ...;
}
...
}
define my_define_helper(...)
{
$n = regsubst($name, '^(.*)//(.*)$', '\1')
$p = regsubst($name, '^(.*)//(.*)$', '\2')
# Do things with $n and $p, which now are the $name and one
# element of $param from my_define, respectively.
}
my_define {
"foo": param => ["a", "b", "c"], ...;
"bar": param => ["a", "b", "c"], ...;
}
One can already do the looping today, but only as long as the
param parameters to My_define[foo] and My_define[bar] doesn't
have any elements in common. (This use case came up in
puppet-users recently, where the poster wanted a definition for
managing PGP keystores, where one parameter would be an array of
keys.
http://groups.google.com/group/puppet-users/browse_thread/thread/d3e85f7869f66ed1)
--
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://reductivelabs.com/redmine/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
-~----------~----~----~----~------~----~------~--~---