On 18 Feb 2011, at 12:29 PM, Luke Kanies wrote:
> On Feb 18, 2011, at 11:37 AM, Ian Ward Comfort wrote:
>> Heh, right. I was trying to think of a clean way to give types a way to say,
>> "autorequire the first of these dependencies that's found in the catalog,
>> and ignore the rest". Adding an autorequirefirst method would do it in a
>> backwards-compatible way, but that feels icky.
>
> It's actually pretty straightforward to do the trimming, I think - we
> currently just return the parent class, but we should instead search through
> possible parent dirs and see which ones are in the catalog. Something like:
>
> autorequire(:file) do
> dirs = File.dirname(self[:path]).split(File::SEPARATOR)[1..-1].inject([""])
> { |list, d| list << File.join(list[-1], d); list }[1..-1].reverse
> parent = dirs.find { |dir| catalog.resource(:file, dir) }
> parent # either nil or a filename; works the same either way
> end
Ah, hmm. Is that legit? Type.autorequire takes rel_catalog, which appears to be
the relative catalog against which autorequires are to be generated, while this
always uses the resource's catalog. But maybe rel_catalog is only supposed to
be for picking the final resources... or, actually, it never seems to be used
anyway.
OK, I'll give this approach a shot.
--
Ian Ward Comfort <[email protected]>
Systems Team Lead, Academic Computing Services, Stanford University
--
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.