[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1601-gf8c1b08

James Turnbull james at lovedthanlost.net
Fri Jan 15 09:07:21 UTC 2010


The following commit has been merged in the upstream branch:
commit be7ff82f92a14f4f572d738eeeb2c77437069c49
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Nov 17 15:58:20 2009 -0800

    Fix 2768 maillist resource is broken
    
    Replace deprecated method call. This code was not tested before, so I've
    tried to capture what I think the method was trying to do.
    
    This version includes Luke's suggested change to better preserve the
    original behavior.
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/type/maillist.rb b/lib/puppet/type/maillist.rb
index e2430aa..4ab9be2 100755
--- a/lib/puppet/type/maillist.rb
+++ b/lib/puppet/type/maillist.rb
@@ -42,13 +42,10 @@ module Puppet
                     should = :absent
                 end
                 atype = Puppet::Type.type(:mailalias)
-                return provider.aliases.collect do |name, recipient|
-                    if atype[name]
-                        nil
-                    else
-                        malias = Puppet::Type.type(:mailalias).new(:name => name, :recipient => recipient, :ensure => should)
-                    end
-                end.compact
+
+                provider.aliases.
+                    reject  { |name,recipient| catalog.resource(:mailalias, name) }.
+                    collect { |name,recipient| atype.new(:name => name, :recipient => recipient, :ensure => should) }
             end
         end
     end
diff --git a/spec/unit/type/maillist.rb b/spec/unit/type/maillist.rb
new file mode 100755
index 0000000..5853366
--- /dev/null
+++ b/spec/unit/type/maillist.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+maillist = Puppet::Type.type(:maillist)
+
+describe maillist do
+    before do
+        @provider_class = Puppet::Type.type(:maillist).provider(:mailman)
+
+        @provider = stub 'provider', :class => @provider_class, :clear => nil
+        @provider.stubs(:respond_to).with(:aliases).returns(true)
+
+        @provider_class.stubs(:new).returns(@provider)
+
+        Puppet::Type.type(:maillist).stubs(:defaultprovider).returns(@provider_class)
+        
+        @maillist = Puppet::Type.type(:maillist).new( :name => 'test' )
+
+        @catalog = Puppet::Resource::Catalog.new
+        @maillist.catalog = @catalog
+    end
+
+    it "should generate aliases unless they already exist" do
+        # Mail List aliases are careful not to stomp on managed Mail Alias aliases
+
+        # test1 is an unmanaged alias from /etc/aliases
+        Puppet::Type.type(:mailalias).provider(:aliases).stubs(:target_object).returns( StringIO.new("test1: root\n") )
+
+        # test2 is a managed alias from the manifest
+        dupe = Puppet::Type.type(:mailalias).new( :name => 'test2' )
+        @catalog.add_resource dupe
+
+        @provider.stubs(:aliases).returns({"test1" => 'this will get included', "test2" => 'this will dropped', "test3" => 'this will get included'})
+
+        generated = @maillist.generate
+        generated.map{ |x| x.name  }.sort.should == ['test1', 'test3']
+        generated.map{ |x| x.class }.should      == [Puppet::Type::Mailalias, Puppet::Type::Mailalias]
+
+    end
+
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list