Issue #7598 has been updated by Daniel Pittman.

I cannot think of any rational way that this could work as desired.  If the 
example was written *without* the extra set of quotes around the array it would 
absolutely do the right thing, but with them?  Madness lies down this path.  
Specifically, what should these do?

    $array = ["one", "two"]
    file { "/tmp/${array}": }
    file { "/tmp/foo": content => "$array" }
    file { "/tmp/bar": content => "foo $array bar" }

The most coherent reading of this request I can see is "when an array variable 
is substituted into a string, behave instead like this construct:

    "foo $array1 $array2 ... $arrayN bar"
    =>
      $result = []
      for $a in $array1 do
        for $b in $array2 do
          # ...
          for $N in $arrayN do
            $result += "foo $a $b ... $N bar"
          end
        end
      end

In other words, you end up with an implicit loop around the string expansion, 
returning an array of strings.  Which then behave exactly like an array of 
strings in that position would.

(Which, incidentally, can radically change the semantics of a string expansion 
when the content of a variable changes.  Imagine if we change Facter to return 
an array in place of a scalar in some value, or worse, some random hardware or 
software change on the system does that... :)

----------------------------------------
Feature #7598: Unpack array variables in string interpolation
https://projects.puppetlabs.com/issues/7598

Author: Randall Hansen
Status: Investigating
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: puppetcamp-eu-2011
Branch: 


If your goal is this (pseudo-code):

    @file { "host_one" }
    @file { "host_two" }

You should be able to say this:

    $array = [ "one", "two" ]
    @file { "host_$array" }

Instead of this:

    @file { "host_one", "host_two" }

--

*This ticket is a request for comment, coming out of a discussion at Puppet 
Camp EU, 2011.  No promises whatever about implementation, but there were 
enough people interested to open a public discussion.*



-- 
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