Hi all,

I have been working on getting composite namevars to work with parsedfile.

It actually seems to get a little sticky for purging, below I am outlining
how it works, I was just curious if anyone has spent time thinking about
this use case before and how it should work:

As far as I can tell, the title_patterns can only map in one direction
title->parameters

(more on why they may have to map the other way in a second :) ).

When we call self.instances during purging, the following series of events
occur (with parsed file)

  - generate each record
        - this is able to generate a record that includes the params that
compose the composite namevar
  - this record (which is a hash) is then converted into a resource
  - when converted into a resources, it calls hash2resource, which picks a
title if one has not been specified:

   910      title = hash.delete(:title)
   911      title ||= hash[:name]
   912      title ||= hash[key_attributes.first] if key_attributes.length ==
1

   - it is impossible for this code to generate a valid title for a
composite title (since it doesn't know how to map backwards from the params
out of the has to the composite title)

now that we have a title that is invalid

  - we call to_hash when we generate the original parameters

@original_parameters = resource.to_hash

   - to_hash tries to parse the title (using def parse_title), which leads
to failures b/c the title is invalid

I can get around this by adding the following pattern:

      # this pattern is required for purging
      [ /^(.*)$/,
        [
          [ :name, lambda{|x| x} ]
        ]
      ]

which is added just for purging

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

Reply via email to