summaryrefslogtreecommitdiffstats
path: root/lib/puppet/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-11 13:59:25 -0800
committerLuke Kanies <luke@madstop.com>2008-02-11 13:59:25 -0800
commit3b740ff7a6ab7127ec5e4935782c33245687c429 (patch)
tree218b8b7e20e01f41fcd8c27107af9ba150531cd8 /lib/puppet/node
parent194e7309c9c481f7e67bd63b13e2fc80fe0a4f00 (diff)
downloadpuppet-3b740ff7a6ab7127ec5e4935782c33245687c429.tar.gz
puppet-3b740ff7a6ab7127ec5e4935782c33245687c429.tar.xz
puppet-3b740ff7a6ab7127ec5e4935782c33245687c429.zip
Converting the Compile class to use a Node::Catalog instance
as its resource container, instead of having its own behaviour around resource uniqueness.
Diffstat (limited to 'lib/puppet/node')
-rw-r--r--lib/puppet/node/catalog.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index 9601309d8..03187cc94 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -64,7 +64,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
else
@resource_table[ref] = resource
end
- resource.catalog = self unless is_relationship_graph
+ resource.catalog = self if resource.respond_to?(:catalog=) and ! is_relationship_graph
add_vertex!(resource)
end
end
@@ -491,4 +491,28 @@ class Puppet::Node::Catalog < Puppet::PGraph
return result
end
+
+ # Verify that the given resource isn't defined elsewhere.
+ def verify_resource_uniqueness(resource)
+ # Short-curcuit the common case,
+ unless existing_resource = @resource_table[resource.ref]
+ return true
+ end
+
+ # Either it's a defined type, which are never
+ # isomorphic, or it's a non-isomorphic type, so
+ # we should throw an exception.
+ msg = "Duplicate definition: %s is already defined" % resource.ref
+
+ if existing_resource.file and existing_resource.line
+ msg << " in file %s at line %s" %
+ [existing_resource.file, existing_resource.line]
+ end
+
+ if resource.line or resource.file
+ msg << "; cannot redefine"
+ end
+
+ raise Puppet::ParseError.new(msg)
+ end
end