On Sun, May 22, 2011 at 4:42 PM, markus <mar...@reality.com> wrote:

>
> > 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
>
> That's correct.  Since it's made up of two non-invertible operations
> (matching a regular expression & mapping through lambdas) there's no
> automatically generated inverse operation.  We (Stephan and I) discussed
> providing support for a converse operation (something like a micro-erb
> template that would produce a title based on the other attributes) but
> since we couldn't come up with compelling use case at the time we
> decided it was out of scope.
>

I am going to be working on a patch for a joiner, I have some other use
cases besides the ones listed below:

- puppet resource (will not print all resources b/c of name collisions)

- I was also getting lots of name collisions when I was plugins:

warning: Limits dan found in both parsed and parsed; skipping the parsed
version



>
> > (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
>
> You, on the other hand, have a pretty good one right there.  :)
>
> >
> >   - 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
>
> Hmmm.  I'm not seeing how that actually fixes it rather than just hiding
> it by setting the name to the title so it can later set the title to the
> name.  I think what's really needed is to have hash2resource be smarter
> about assigning a title...which may be what you're saying as well.
>
>
I was not saying that it fixed it, I was saying here is a dirty hack I have
to do that seems to fix it.

After further progressing into the problem, I have realized that it just
masked my one issue so that I could encounter other issues :)


> -- Markus
>
>
> --
> 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.
>
>

-- 
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