summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/compiler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/compiler.rb')
-rw-r--r--lib/puppet/parser/compiler.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index 8e84f5a5b..fd7d9680b 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -21,13 +21,17 @@ class Puppet::Parser::Compiler
raise Puppet::Error, "#{detail} on node #{node.name}"
end
- attr_reader :node, :facts, :collections, :catalog, :node_scope, :resources
+ attr_reader :node, :facts, :collections, :catalog, :node_scope, :resources, :relationships
# Add a collection to the global list.
def add_collection(coll)
@collections << coll
end
+ def add_relationship(dep)
+ @relationships << dep
+ end
+
# Store a resource override.
def add_override(override)
# If possible, merge the override in immediately.
@@ -144,6 +148,10 @@ class Puppet::Parser::Compiler
found
end
+ def evaluate_relationships
+ @relationships.each { |rel| rel.evaluate(catalog) }
+ end
+
# Return a resource by either its ref or its type and title.
def findresource(*args)
@catalog.resource(*args)
@@ -337,6 +345,8 @@ class Puppet::Parser::Compiler
# Make sure all of our resources and such have done any last work
# necessary.
def finish
+ evaluate_relationships()
+
resources.each do |resource|
# Add in any resource overrides.
if overrides = resource_overrides(resource)
@@ -374,6 +384,9 @@ class Puppet::Parser::Compiler
# but they each refer back to the scope that created them.
@collections = []
+ # The list of relationships to evaluate.
+ @relationships = []
+
# For maintaining the relationship between scopes and their resources.
@catalog = Puppet::Resource::Catalog.new(@node.name)
@catalog.version = known_resource_types.version