Hello,

I've been working on supporting recursive dependency checks in rspec-puppet 
today.

I have a PR for that at https://github.com/rodjek/rspec-puppet/pull/261

Unfortunately, I have had to scratch my head for quite a few things, and 
I'd love to some ideas from you, fellow puppet devs!

One ugly thing I've had to do is to canonicalize resources.

def canonicalize_resource(resource)
  resource_from_ref(resource_ref(resource))
end


The problem I'm trying to solve is that when I have a resource reference, I 
need to retrieve the corresponding resource from the catalog. 
@catalogue.resource(ref) does that, but it sometimes returns a "partial" 
resource. For example, with file resources, the resource might have a 
"path" parameter, but resource[:path] returns nil.

In Puppet 3.7.4, I managed to "fix" this by canonicalizing the resource 
with @catalog.resource(resource.to_ref). I have no idea why that works 
actually.

However, in older versions of Puppet, I haven't found a way to retrieve 
this "full" version of the resource that can actually be passed to 
autorequire blocks safely.

Another problem, probaly more fundamental, is that I need to process 
resource dependencies recursively. I managed to do so with a double loop, 
but I suspect it should be doable using @catalogue.relationship_graph. 
However, I've spent quite a bit of time playing with all the methods I 
could think of, and couldn't figure out how to compute the relationship 
between two resources using the relationship_graph. I ended up using 
@catalogue.upstream_from_vertex, which doesn't work with Puppet 2.6.18 (see 
Travis CI build).


Do you have any pointers to improve this PR and make it work with all 
(supported) versions of Puppet?

Other remarks regarding the feature itself are also welcome of course!


Cheers,

Raphaël

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/91e6e6c8-5782-4c16-9b34-2ef15b1aabd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to