This patch works, but is deprecated in favour of a more general solution
that's in the works.  Specific responses to comments below.

> -        if argtitle.nil?
> > -            if argtype.is_a?(Puppet::Type)
> > -                self.title = argtype.title
> > -                self.type = argtype.class.name
> > -            else
> > -                self.title = argtype
> > -                if self.title == argtype
> > -                    raise ArgumentError, "No title provided and
> > title '%s' is not a valid resource reference" % argtype.inspect
> > -                end
> > -            end
> > -        else
> > -            # This will set @type if it looks like a resource
> > reference.
> > -            self.title = argtitle
> > -
> > -            # Don't override whatever was done by setting the title.
> > -            self.type ||= argtype
> > -        end
> > -
> > +        self.type,self.title =
> > +         if    (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/ then
> > [ $1,                 $2            ]
> > +         elsif argtitle                                        then
> > [ argtype,            argtitle      ]
> > +         elsif argtype.is_a?(Puppet::Type)                     then
> > [ argtype.class.name, argtype.title ]
> > +         else raise ArgumentError, "No title provided and
> > #{argtype.inspect} is not a valid resource reference"
> > +         end
>
> Does this actually change behaviour?  If not, seems a bit weird to
> include it here.
>

It doesn't change the outcome of the code by itself but it does reduce the
data flow to a simple path were we're sure that @value will get set exactly
once and that @type (needed for canonicalization) will be set before we call
self.value=.



>
> > +        def self.canonicalize_title(s)
> > +            # Get rid of any duplicate slashes, and remove any
> > trailing slashes unless
> > +            # the title is just a slash, in which case leave it.
> > +            s.gsub(/\/+/, "/").sub(/(.)\/$/,'\1')
> > +        end
> > +
> > +
>
> So we're just canonicalizing titles?  This means something like:
>
> file { foo: path => "/foo/bar/" }
>
> will still trigger the failure, right?
>

No.  This is poorly named.  It's canonicalizing reference titles, not
resource titles.  It's been renamed to "canonicalize_ref" in the forthcoming
patch.

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