On Thu, Aug 7, 2014 at 12:55 PM, Henrik Lindberg < henrik.lindb...@cloudsmith.com> wrote:
> On 2014-07-08 20:09, Ben Ford wrote: > >> I would also like to propose that we use the metaparameter syntax for >> defaults as well. >> >> For example, rather than writing this: >> >> #less readable >> >> file { >> >> default: >> >> mode => '0666'; >> >> '/tmp/foo': ; >> '/tmp/bar': ; >> >> '/tmp/special': >> mode => '0777'; >> } >> >> One would write this: >> >> >> #more readable >> >> $defaults = { >> >> ensure => file, >> >> mode => '0666', >> >> } >> file { [ '/tmp/foo', '/tmp/bar' ]: >> >> attribute_defaults => $defaults, >> >> } >> file { '/tmp/special': >> mode => '0777', >> attribute_defaults => $defaults, >> } >> >> >> The benefits to that approach are that it looks & feels more like the >> Puppet language, it's less of a conceptual change going forward, and >> it's also easily searchable. It's also possible have multiple default >> hash variables in scope and just assign them as needed. >> >> > This requires a user to repeat the defaults per titled resource body. > > Your example can also be written like this: > > file { [ '/tmp/foo', '/tmp/bar' ]: > attribute => $defaults, > > } > > file { '/tmp/special': > mode => '0777', > attributes => $defaults - mode, > } > > > - henrik > > I was muddling through a similar email, but Henrik beat me to the point; the only thing I have to add is that I find attribute_defaults more confusing than an explicit defaults: section because of the added confusion regarding how the attributes mesh. Explicit attributes and attributes => $more would raise an error if they set the same attributes, but attribute_defaults => $defaults would presumably be overwritten. -- Josh Partlow jpart...@puppetlabs.com Developer, Puppet Labs Join us at PuppetConf 2014, September 20-24 in San Francisco Register by September 8th to take advantage of the Final Countdown —save $149! -- 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/CADxAQ5osGdD2%3D_mkjktKmFdU%2B2sRpca26HL%2BYR8yHqJJpY9irw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.