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 <[email protected]>
---
 lib/puppet/parser/resource.rb |    6 ++++++
 spec/unit/parser/resource.rb  |   15 ++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)

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
-- 
1.6.3.3


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to