summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-11-07 16:55:00 -0600
committerLuke Kanies <luke@madstop.com>2008-11-07 16:55:00 -0600
commit45c6382e99c3e4c4c9bc85fef35a4114b1d1fb46 (patch)
treecc1853a2f53dddc76debdc1e9d92f19210a8c2cd /lib/puppet
parent084071936738f25930bc99bb2e62c2a52259e915 (diff)
downloadpuppet-45c6382e99c3e4c4c9bc85fef35a4114b1d1fb46.tar.gz
puppet-45c6382e99c3e4c4c9bc85fef35a4114b1d1fb46.tar.xz
puppet-45c6382e99c3e4c4c9bc85fef35a4114b1d1fb46.zip
Finishing the refactoring of the resource generation interface.
All of the code works, and there are integration tests all around to prove it. I think. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction.rb13
-rw-r--r--lib/puppet/type/file.rb22
2 files changed, 12 insertions, 23 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 333e8965a..0f94f5a12 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -160,7 +160,7 @@ class Transaction
# Copy an important relationships from the parent to the newly-generated
# child resource.
- def copy_relationships(resource, children)
+ def make_parent_child_relationship(resource, children)
depthfirst = resource.depthfirst?
children.each do |gen_child|
@@ -169,7 +169,7 @@ class Transaction
else
edge = [resource, gen_child]
end
- relationship_graph.add_resource(gen_child) unless relationship_graph.resource(gen_child.ref)
+ relationship_graph.add_vertex(gen_child)
unless relationship_graph.edge?(edge[1], edge[0])
relationship_graph.add_edge(*edge)
@@ -228,13 +228,6 @@ class Transaction
end
end
- # Create a child/parent relationship. We do this after everything else because
- # we want explicit relationships to be able to override automatic relationships,
- # including this one.
- if children
- copy_relationships(resource, children)
- end
-
# A bit of hackery here -- if skipcheck is true, then we're the
# top-level resource. If that's the case, then make sure all of
# the changes list this resource as a proxy. This is really only
@@ -353,6 +346,8 @@ class Transaction
made.each do |res|
@catalog.add_resource(res) { |r| r.finish }
end
+ make_parent_child_relationship(resource, made)
+ made
end
# Collect any dynamically generated resources. This method is called
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index dfb909f3f..ccef61253 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -331,16 +331,15 @@ module Puppet
# Create any children via recursion or whatever.
def eval_generate
- return nil unless self.recurse?
+ return [] unless self.recurse?
- raise(Puppet::DevError, "Cannot generate resources for recursion without a catalog") unless catalog
-
- recurse.reject do |resource|
- catalog.resource(:file, resource[:path])
- end.each do |child|
- catalog.add_resource child
- catalog.relationship_graph.add_edge self, child
- end
+ recurse
+ #recurse.reject do |resource|
+ # catalog.resource(:file, resource[:path])
+ #end.each do |child|
+ # catalog.add_resource child
+ # catalog.relationship_graph.add_edge self, child
+ #end
end
def flush
@@ -487,7 +486,6 @@ module Puppet
end
return self.class.create(options)
- #return catalog.create_implicit_resource(:file, options)
end
# Files handle paths specially, because they just lengthen their
@@ -517,10 +515,6 @@ module Puppet
@parameters.include?(:purge) and (self[:purge] == :true or self[:purge] == "true")
end
- def make_children(metadata)
- metadata.collect { |meta| newchild(meta.relative_path) }
- end
-
# Recursively generate a list of file resources, which will
# be used to copy remote files, manage local files, and/or make links
# to map to another directory.