]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
let icmp param accept integers in addition to strings
authorJonathan Boyett <jonathan@failingservers.com>
Thu, 16 Jun 2011 21:46:29 +0000 (14:46 -0700)
committerJonathan Boyett <jonathan@failingservers.com>
Thu, 16 Jun 2011 21:46:29 +0000 (14:46 -0700)
lib/puppet/type/firewall.rb
spec/type/iptables_type_spec.rb

index 2d6531d2f4012aad524d98c9a97474b38a704c66..00a4274ab22a96988d5878893906f5c1917df6e3 100644 (file)
@@ -153,11 +153,16 @@ Puppet::Type.newtype(:firewall) do
     desc "The value for the iptables --icmp-type parameter"
 
     munge do |value|
-      num = @resource.icmp_name_to_number(value)
-      if num == nil && value != ""
+      if value.kind_of?(String)
+        value = @resource.icmp_name_to_number(value)
+      else
+        value
+      end
+
+      if value == nil && value != ""
         self.fail("cannot work out icmp type")
       end
-      num
+      value
     end
   end
 
index 8ff371541128c5d0795b764d8a8daec38a32ee22..aa8480d3d7146f456f529984783935b778d4752e 100644 (file)
@@ -140,6 +140,11 @@ describe Puppet::Type.type(:firewall) do
       end
     end
 
+    it 'should accept values as integers' do
+      @resource[:icmp] = 9
+      @resource[:icmp].should == 9
+    end
+
     it 'should fail if icmp type is not recognized' do
       lambda { @resource[:icmp] = 'foo' }.should raise_error(Puppet::Error)
     end