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

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:06:17 UTC 2009


The following commit has been merged in the upstream branch:
commit 73d04c6b15e1b626cd7dea1f963a5ca02a810137
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Mon Oct 26 00:43:29 2009 -0700

    Bug #2534 Raise error if property appears twice
    
    This patch changes Puppet::Parser::Resource to check if it has been
    passed two Puppet::Parser::Resource::Param objects with the same name.
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index b8aaf27..651ed42 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -139,6 +139,12 @@ class Puppet::Parser::Resource
         if params = options[:params]
             options.delete(:params)
             params.each do |param|
+                # Don't set the same parameter twice
+                if @params[param.name]
+                    self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" %
+                        [param.name, self.to_s]
+                end
+
                 set_parameter(param)
             end
         end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 0a67c4b..3f08de9 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -25,7 +25,7 @@ describe Puppet::Parser::Resource do
         params = args[:params] || {:one => "yay", :three => "rah"}
         if args[:params] == :none
             args.delete(:params)
-        else
+        elsif not args[:params].is_a? Array
             args[:params] = paramify(args[:source], params)
         end
 
@@ -483,5 +483,18 @@ describe Puppet::Parser::Resource do
             result = @parser_resource.to_resource
             result[:fee].should == ["a", Puppet::Resource::Reference.new(:file, "/my/file1"), Puppet::Resource::Reference.new(:file, "/my/file2")]
         end
+
+        it "should fail if the same param is declared twice" do
+            lambda do 
+                @parser_resource = mkresource :source => @source, :params => [
+                    Puppet::Parser::Resource::Param.new(
+                        :name => :foo, :value => "bar", :source => @source
+                    ),
+                    Puppet::Parser::Resource::Param.new(
+                        :name => :foo, :value => "baz", :source => @source
+                    )
+                ]
+            end.should raise_error(Puppet::ParseError)
+        end
     end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list