diff options
author | Luke Kanies <luke@madstop.com> | 2008-11-05 21:44:42 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-11-05 21:44:42 -0600 |
commit | 35c623e65b44fed098374288e8c1dfc450a1f9f7 (patch) | |
tree | 0d000c4b3b48904e95142ce3a6f39b44d1e67143 | |
parent | f4800e8aeb6196aebc43d36f69b2e2a182d1bf5c (diff) | |
download | puppet-35c623e65b44fed098374288e8c1dfc450a1f9f7.tar.gz puppet-35c623e65b44fed098374288e8c1dfc450a1f9f7.tar.xz puppet-35c623e65b44fed098374288e8c1dfc450a1f9f7.zip |
Removing mid-transaction resources from the catalog.
This basically just cleans up dynamic resources.
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/node/catalog.rb | 2 | ||||
-rwxr-xr-x | spec/unit/node/catalog.rb | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index 852904967..39b3fdfdc 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -68,6 +68,7 @@ class Puppet::Node::Catalog < Puppet::PGraph ref = resource.ref + @transient_resources << resource if applying? @resource_table[ref] = resource # If the name and title differ, set up an alias @@ -199,7 +200,6 @@ class Puppet::Node::Catalog < Puppet::PGraph end return unless resource = klass.create(options) - @transient_resources << resource if applying? add_resource(resource) if @relationship_graph @relationship_graph.add_resource(resource) unless @relationship_graph.resource(resource.ref) diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb index c986fc24e..68b8af347 100755 --- a/spec/unit/node/catalog.rb +++ b/spec/unit/node/catalog.rb @@ -784,6 +784,20 @@ describe Puppet::Node::Catalog, " when creating a relationship graph" do @catalog.resource("File[/yay]").should be_nil end + it "should remove resources added mid-transaction" do + @transaction = mock 'transaction' + Puppet::Transaction.stubs(:new).returns(@transaction) + @transaction.stubs(:evaluate) + @transaction.stubs(:cleanup) + @transaction.stubs(:addtimes) + file = Puppet::Type.type(:file).create(:name => "/yay", :ensure => :file) + @catalog.apply do |trans| + @catalog.add_resource file + @catalog.resource("File[/yay]").should_not be_nil + end + @catalog.resource("File[/yay]").should be_nil + end + it "should remove resources from the relationship graph if it exists" do @catalog.remove_resource(@one) @catalog.relationship_graph.vertex?(@one).should be_false |