summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorRein Henrichs <reinh@reinh.com>2009-11-11 11:17:13 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-13 08:32:19 +1100
commit53f40bd336d709e717edb621a9d68dde9a4d5bce (patch)
treed119798f1bd34b49ea58aa8436ae20e9286a2577 /lib/puppet
parent3fdc8effbe25c9653d8bc86f2d4847984d4cb6f3 (diff)
downloadpuppet-53f40bd336d709e717edb621a9d68dde9a4d5bce.tar.gz
puppet-53f40bd336d709e717edb621a9d68dde9a4d5bce.tar.xz
puppet-53f40bd336d709e717edb621a9d68dde9a4d5bce.zip
Fix #2681 Incorrectly duplicating resources
Ensure that resources whose refs are included in the catalog are skipped to avoid duplication. * Refactor to avoid early bailout on resources that cannot be ensured absent. * Remove check for managed? in generate Checking if a resource is managed is unnecessary when checking for its inclusion in the catalog. * Add test coverage for Puppet::Type::Resources#generate
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type/resources.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index 87bde972b..e1de55711 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -99,18 +99,18 @@ Puppet::Type.newtype(:resources) do
def generate
return [] unless self.purge?
resource_type.instances.
- reject { |r| managed? }.
- reject { |r| catalog.resources.include? r.ref }.
- select { |r| check(r) }.
- select { |r| able_to_ensure_absent?(r) }.
- each { |resource|
- @parameters.each do |name, param|
- resource[name] = param.value if param.metaparam?
- end
-
- # Mark that we're purging, so transactions can handle relationships
- # correctly
- resource.purging
+ reject { |r| catalog.resources.include? r.ref }.
+ select { |r| check(r) }.
+ select { |r| r.class.validproperty?(:ensure) }.
+ select { |r| able_to_ensure_absent?(r) }.
+ each { |resource|
+ @parameters.each do |name, param|
+ resource[name] = param.value if param.metaparam?
+ end
+
+ # Mark that we're purging, so transactions can handle relationships
+ # correctly
+ resource.purging
}
end