On 23/05/17 20:21, Dean Wilson wrote:
Hi,
  I'm currently trying to write a Puppet 4, EPP, version of
https://forge.puppet.com/deanwilson/multitemplate but I'm having an
issue with the dispatch rules I'd like to use.

In order to support multiple template file names, and provide values
for the templates, I think I want something like this (but with a
better Pattern):

  dispatch :template_data do
    scope_param
    repeated_param 'String', :templates
    param 'Hash[Pattern[/^\w+$/], Any]', :parameters
  end

But that's not allowed as repeated patterns have to be the last thing
(excluding blocks.) I know in modern rubies you can have a 'splat' in
the middle and unpack the first and last params so I was wondering if
it'd be considered for puppet function dispatch too.


We did consider adding that but rejected the idea. Mostly because the varargs concept exists in most languages (as last param), but not somewhere in the middle.

Why not simply switch the arguments around so you have the list of files at the end of the list?

- henrik

I can currently get around this with a call like
multi_epp_template(['file', 'file2'], { }) but that extra bit of array
syntax feels unwieldy.

In general the puppet 4 function dispatch stuff has been quite nice to
work with, so congrats on that.

Glad you like it.

- henrik

  Dean



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/og23lu%24h1p%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to