On Jun 6, 2010, at 2:07 PM, David Schmitt wrote:

Am 06.06.2010 01:30, schrieb Markus Roberts:
   It seems to me we kind of have two problems:  How to uniquely
   specify the resource with parameters, and how to specify it with a
   resource reference.  Your solution (the title becomes a template
filled in by the different parameters) does kind of neatly solve it, but I'm afraid it might be too complicated for normal humans to use.


Playing around with it at puppet came we came to the conclusion that,
while it could in principle get too complicated to use, in the actual
use cases it was dead obvious what was intended--in part because the
formats we are wanting to model are themselves extremely well known.

What I think you were referring to ("title becomes a template") was only meant for documentation generation. (Ab-)Using this as a way to create a canonical title, seems to magical to me.

I failed to include a little bit of code to actually make the title generation explicit. There should be a separate, explicit code-block in the newtitle that creates the canonical title from the resource:

   newtitle do
     # match incoming parameters
     pattern "([...@]+)@([...@]+)", :user, :host
     pattern "([...@]+)", :user

     # produce canonical title form for referencing
     canonical_form do
       "%...@%s" % [ @resource[:user], @resource[:host] ]
     end
   end

Especially on the file type, which has very different syntaxes for the same property combinations (eg: "host:/share" for NFS and "\\host \share" for UNC) whould need more intelligence than simple substitution for title generation, while for documentation it would still work.


On a completely side note, apparently one of the code smells in Puppet's existing internal DSL around building resource types is the use of 'new' in method names. So I recommend going with just 'title' or something similar for the method name.

--
Dawkins's Law of Adversarial Debate:
    When two incompatible beliefs are advocated with equal intensity,
    the truth does not lie half way between them.
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" 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-dev?hl=en.

Reply via email to