diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-10 15:18:30 -0600 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-02-11 09:11:31 +1100 |
| commit | 32c2be926795ce3ce68f573367f7700e87ac8416 (patch) | |
| tree | ae52417826c45d25876f06affe5e1d5e4fbd1eb0 | |
| parent | 0e491591d2ab88938f9b127dd8c26033e817eb1a (diff) | |
| download | puppet-32c2be926795ce3ce68f573367f7700e87ac8416.tar.gz puppet-32c2be926795ce3ce68f573367f7700e87ac8416.tar.xz puppet-32c2be926795ce3ce68f573367f7700e87ac8416.zip | |
Fixed #1884 - exported defines are collected by the exporting host
This was caused by the fix to #1472. That fix unexported
any resources collected from the local catalog.
The crux of this fix is that it separates 'exported'
and 'virtual' a bit more. It also removes no-longer-needed
functionality where resources copied their virtual or
exported bits from the enclosing define or class. This is
now obsolete because we don't evaluate virtual defined resources.
The crux of this commit is that defined resources can stay
exported even though they're evaluated, and that exported state
won't inherit to contained resources such that those then don't
get evaluated.
Signed-off-by: Luke Kanies <luke@madstop.com>
| -rw-r--r-- | CHANGELOG | 3 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/resource.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/parser/collector.rb | 3 | ||||
| -rwxr-xr-x | spec/unit/parser/ast/resource.rb | 19 | ||||
| -rwxr-xr-x | spec/unit/parser/collector.rb | 8 |
5 files changed, 25 insertions, 11 deletions
@@ -1,5 +1,8 @@ 0.24.8 + Fixed #1884 - Exported resources are marked as unexported when collected on the exporting host + Fixed #1922 - Functions squash all arguments into a single hash + Fixed #1538 - Yumrepo sets permissions wrongly on files in /etc/yum.repos.d Fixed #1936 - Added /* */ support to the vim file diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index eb0bdeac4..d222893b3 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -32,8 +32,7 @@ class Resource < AST::ResourceReference # because sometimes the :virtual attribute is set *after* # :exported, in which case it clobbers :exported if :exported # is true. Argh, this was a very tough one to track down. - exp = self.exported || scope.resource.exported? - virt = self.virtual || scope.resource.virtual? || exp + virt = self.virtual || self.exported # This is where our implicit iteration takes place; if someone # passed an array as the name, then we act just like the called us diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 0f9072510..bcba9528e 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -72,8 +72,7 @@ class Puppet::Parser::Collector def collect_exported # First get everything from the export table. Just reuse our # collect_virtual method but tell it to use 'exported? for the test. - resources = collect_virtual(true).reject { |r| ! r.virtual? }.each { |r| r.exported = false } - #resources = collect_virtual(true).reject { |r| ! r.virtual? } + resources = collect_virtual(true).reject { |r| ! r.virtual? } count = resources.length diff --git a/spec/unit/parser/ast/resource.rb b/spec/unit/parser/ast/resource.rb index 1546d657f..b257cb116 100755 --- a/spec/unit/parser/ast/resource.rb +++ b/spec/unit/parser/ast/resource.rb @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe Puppet::Parser::AST::Resource do - ast = Puppet::Parser::AST before :each do @@ -19,7 +18,6 @@ describe Puppet::Parser::AST::Resource do end it "should evaluate all its parameters" do - @param1.expects(:safeevaluate).with(@scope) @resource.evaluate(@scope) @@ -86,5 +84,20 @@ describe Puppet::Parser::AST::Resource do @resource.title = titles @resource.evaluate(@scope).should == [resource] end -end + it "should generate virtual resources if it is virtual" do + @resource.virtual = true + + Puppet::Parser::Resource.expects(:new).with { |hash| hash[:virtual] == true } + + @resource.evaluate(@scope) + end + + it "should generate virtual and exported resources if it is exported" do + @resource.exported = true + + Puppet::Parser::Resource.expects(:new).with { |hash| hash[:virtual] == true and hash[:exported] == true } + + @resource.evaluate(@scope) + end +end diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb index ede583b96..59d62d6d8 100755 --- a/spec/unit/parser/collector.rb +++ b/spec/unit/parser/collector.rb @@ -240,10 +240,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do one = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true two = stub 'two', :type => "Mytype", :virtual? => true, :exported? => true - one.expects(:exported=).with(false) - one.expects(:virtual=).with(false) - two.expects(:exported=).with(false) - two.expects(:virtual=).with(false) + one.stubs(:exported=) + one.stubs(:virtual=) + two.stubs(:exported=) + two.stubs(:virtual=) @compiler.expects(:resources).returns([one, two]) |
