diff --git a/CHANGELOG b/CHANGELOG index a405f951d..3612bffdd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ + Collection of resources now correctly only collects exported + resources again. This was broken in 0.23.0. (#731) + 'gen_config' now generates a configuration with all parameters under a heading that matches the process name, rather than keeping section headings. diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 62eafdd65..6c49c6d57 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -23,7 +23,7 @@ class Puppet::Parser::Collector host = Puppet::Rails::Host.find_by_name(@scope.host) args = {:include => {:param_values => :param_name}} - args[:conditions] = "restype = '%s'" % [@type] + args[:conditions] = "(exported = 't' AND restype = '%s')" % [@type] if @equery args[:conditions] += " AND (%s)" % [@equery] end diff --git a/test/rails/collection.rb b/test/rails/collection.rb index 005d4502c..d878641be 100755 --- a/test/rails/collection.rb +++ b/test/rails/collection.rb @@ -209,6 +209,39 @@ class TestRailsCollection < PuppetTest::TestCase assert(ret.empty?, "Found exports from our own host") end + + # #731 -- we're collecting all resources, not just exported resources. + def test_only_collecting_exported_resources + railsinit + + # Make our configuration + host = Puppet::Rails::Host.new(:name => "myhost") + + host.resources.build(:title => "/tmp/exporttest1", :restype => "file", + :exported => true) + host.resources.build(:title => "/tmp/exporttest2", :restype => "file", + :exported => false) + + host.save + + @scope.host = "otherhost" + + # Now make a collector + coll = nil + assert_nothing_raised do + coll = Puppet::Parser::Collector.new(@scope, "file", nil, nil, :exported) + end + + # And make sure we get nada back + ret = nil + assert_nothing_raised do + ret = coll.collect_exported + end + + names = ret.collect { |res| res.title } + + assert_equal(%w{/tmp/exporttest1}, names, "Collected incorrect resource list") + end end # $Id$