On Nov 3, 2010, at 6:38 AM, jcbollinger wrote:

> 
> 
> On Nov 2, 11:43 am, Nigel Kersten <ni...@puppetlabs.com> wrote:
>> On Tue, Nov 2, 2010 at 4:32 PM, Patrick <kc7...@gmail.com> wrote:
>> 
>>> On Nov 2, 2010, at 9:14 AM, Michael Gliwinski wrote:
>> 
>>>> On Tuesday 02 Nov 2010 15:06:19 Nigel Kersten wrote:
>> 
>>>>> Thanks. There's one thing I'm not quite clear on.
>> 
>>>>> This proposal means we have concatenation and find-first-existing
>>>>> support for the source parameter, and concatenation for the template
>>>>> function, but how are we proposing we provide find-first-existing
>>>>> support for the template and file functions? Or are we dropping that
>>>>> goal?
>> 
>>>> I believe that was by either passing an array or multiple arguments, no?
>>>> E.g.:
>> 
>>>> find-first-existing:
>> 
>>>>  file('foo', 'bar')
>>>>  template('foo.erb', 'bar.erb')
>> 
>>>> concatenation:
>> 
>>>>  concat(file('foo'), file('bar'))
>>>>  concat(template('foo.erb'), template('bar.erb'))
>> 
>>>> that way you can even mix them ;)
>> 
>>>>  concat(file('header'), template("foo.$host.erb", "foo.erb"))
>> 
>>> The proposal I was supporting (and the one in the bug tracker) retained 
>>> backward compatibility which means that passing more than one file to 
>>> template() still concatenates.  That is deprecated though.
>> 
>>> *) Would creating a function that says, 'return the first argument that 
>>> doesn't throw an exception' be useful?
>>> *) Is it even feasible to write?
>> 
>> maybe... I'm having trouble thinking of a decent name for this though :)
>> 
>>> *) Also, I'm assuming that file() and template() throw an exception if the 
>>> file doesn't exist.  Does anyone know if that's true?
>> 
>> From memory they do, but I'll have to double check.
>> 
>>> *) Also, what would you name this function?
>> 
>>> I'm thinking that if we do take this approach, it should be split off into 
>>> another ticket.
>> 
>> I kind of disagree with splitting it off.
>> 
>> Perhaps I didn't express myself well, but my main impetus was to make
>> the source/file/template data specifications *all* support the
>> find-first-existing and concatenation functionality in a sane and
>> consistent manner.
> 
> As Patrick already wrote, the proposal that seemed to garner broad
> acceptance maintains backwards compatibility by preserving, but
> deprecating, template()'s concatentation feature.  If the function is
> only supposed to be passed one argument, then the question of find-
> first does not arise.
> 
> If there is a desire for find-first functionality for template(), then
> I think the most general solution would be some version of Patrick's
> suggested function for determining which file name to use, whether it
> be named "coalesce", "first_file", "find_first", "first_existing",
> "choose", "options", or something else.  Thus:
> 
> template( find_first("t1", "t2") )
> 
> In that case, you might also consider deprecating multiple arguments
> to the file() function in favor of this new approach (i.e.
> file( find_first("foo", "bar") ) instead of file("foo", "bar") ).
> 
> Alternatively, a variant version of template() could be added that
> provides find-first semantics.  It could be named template_choose, or
> some similar thing.  I prefer the other approach, though.

This is what I wanted except reversed.  I was assuming that find_first() can't 
open or find files.  It can only look at what it returned to it, so the syntax 
would be:

find_first( file('foo'), file('bar') )
or
find_first( template('foo'), template('bar') )
or even
find_first( file('foo'), template('bar') )

I think this order gives you more flexibility.  Also, you might be able to put 
a generate() function in there to depending on implementation.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to