]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
(GH-129) Replace errant return in autoreq block
authorDan Carley <dan.carley@gmail.com>
Sun, 3 Mar 2013 14:32:38 +0000 (14:32 +0000)
committerDan Carley <dan.carley@gmail.com>
Sun, 3 Mar 2013 14:32:38 +0000 (14:32 +0000)
It's not valid to use `return` within a block. We could use `next []`,
however it's probably better form to just always return the array, whether
it's populated or not. This will stop the error:

    err: Got an uncaught exception of type LocalJumpError: unexpected return

When one of the listed providers isn't selected. Which is suitable, because
this autorequire won't be suitable to any other future providers anyway.

lib/puppet/type/firewall.rb

index 4f9ee4f27072692bf1d1d10fbde768a319d2bd77..2fd0f00ed49dfc07222fefcd64051446f91d4ab2 100644 (file)
@@ -559,18 +559,20 @@ Puppet::Type.newtype(:firewall) do
   end
 
   autorequire(:firewallchain) do
+    reqs = []
+    protocol = nil
+
     case value(:provider)
     when :iptables
       protocol = "IPv4"
     when :ip6tables
       protocol = "IPv6"
-    else
-      return
     end
 
-    reqs = []
-    [value(:chain), value(:jump)].each do |chain|
-      reqs << "#{chain}:#{value(:table)}:#{protocol}" unless chain.nil?
+    unless protocol.nil?
+      [value(:chain), value(:jump)].each do |chain|
+        reqs << "#{chain}:#{value(:table)}:#{protocol}" unless chain.nil?
+      end
     end
 
     reqs