I am reading over the release notes for Puppet 3.3, and buried under "data 
in modules" is a link to ARM-9.
 
There is a good chance that I don't "get it" - Puppet is moving pretty fast 
these days and I am still trying to get caught up with all of the changes.

I have only read the latest Puppet code and the ARM docs- I have not tried 
it on a real system yet. However, I am concerned about the usefullness of 
the default lookup syntax. I find the examples in the ARM document a bit 
obtuse.
https://github.com/puppetlabs/armatures/blob/master/arm-9.data_in_modules/index.md#lookup-with-default

With hiera1, we can (very simply) do:
  hiera("namespace::key_name", <default value> )

Hiera2 requires some more work:
 $x = lookup('something')
 $looked_up = $x ? { undef => 'nothing', default => $x }

This is ugly. Checking if variables are undefined, and then setting them to 
a default is what we did in bash. Not good.

On the positive side, the lookup function adds a static type checker, but 
it also fails to be completely useful because we cannot (?) define our own 
static types or validators. If we had the ability to define our own type 
check via lambda or other function, this would be useful. We could do 
complex validation on data, more than just 'string' or 'array'.

I would like to see something like:
lookup("namespace::key_name", custom_validator_function)

Where the custom_validator_function could be any puppet parser function OR 
since we now worship the* *great *λ, *we should be able to use an anonymous 
function 
in-place to validate the input (and in this fictitious example, set a 
default value):
lookup("namespace::key_name", |$val| {$val or "default value"} )


To sum it up, as someone who writes a lot of Puppet DSL code, I find the 
hiera1 syntax much more useful than the lookup syntax in ARM-9.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to