]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Deprecate port parameter
authorHunter Haugen <hunter@puppetlabs.com>
Mon, 17 Aug 2015 22:22:04 +0000 (15:22 -0700)
committerHunter Haugen <hunter@puppetlabs.com>
Wed, 19 Aug 2015 17:58:52 +0000 (10:58 -0700)
I couldn't find any valid use case for port, and if any valid case did
exist then sport+dport could be used.

README.markdown
lib/puppet/type/firewall.rb
spec/fixtures/iptables/conversion_hash.rb
spec/unit/puppet/type/firewall_spec.rb

index efba70b33edf184be5e90851dfd0d650ef437ddc..f2b46a0bd9b5943bb3a68a4e2f335ea9f7016e3f 100644 (file)
@@ -621,7 +621,7 @@ firewall { '999 this runs last':
 
 * `pkttype`: Sets the packet type to match. Valid values are: 'unicast', 'broadcast', and'multicast'. Requires the `pkttype` feature.
 
-* `port`: The destination or source port to match for this filter (if the protocol supports ports). Will accept a single element or an array. For some firewall providers you can pass a range of ports in the format: 'start number-end number'. For example, '1-1024' would cover ports 1 to 1024.
+* `port`: *DEPRECATED* The destination or source port to match for this filter (if the protocol supports ports). Will accept a single element or an array. For some firewall providers you can pass a range of ports in the format: 'start number-end number'. For example, '1-1024' would cover ports 1 to 1024.
 
 * `proto`: The specific protocol to match for this rule. This is 'tcp' by default. Valid values are:
   * 'tcp'
index 1ae9d39c374bf853e45e45fa998e524bb1dff6f6..250565544f23e4843e5061d1136fe49792b2616c 100644 (file)
@@ -272,6 +272,8 @@ Puppet::Type.newtype(:firewall) do
 
   newproperty(:port, :array_matching => :all) do
     desc <<-EOS
+      DEPRECATED
+
       The destination or source port to match for this filter (if the protocol
       supports ports). Will accept a single element or an array.
 
@@ -286,6 +288,10 @@ Puppet::Type.newtype(:firewall) do
       This would cover ports 1 to 1024.
     EOS
 
+    validate do |value|
+      Puppet.warning("port is deprecated and will be removed. Use dport and/or sport instead.")
+    end
+
     munge do |value|
       @resource.string_to_port(value, :proto)
     end
index d6db2787eaf47722cbefd6e5a6f47bec29bd667d..ac9ba9a9647bf811d25b24b6971bf7be2809047a 100644 (file)
@@ -775,14 +775,6 @@ HASH_TO_ARGS = {
     },
     :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '000 allow symbols ( $+<=>^`|~ ) in ruby >= 1.9'],
   },
-  'port_property' => {
-    :params => {
-      :name => '001 port property',
-      :table => 'filter',
-      :port => '80',
-    },
-    :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--ports', '80', '-m', 'comment', '--comment', '001 port property'],
-  },
   'log_level_debug' => {
     :params => {
       :name => '956 INPUT log-level',
index 8107e1e5e6c831fc610c2c6fcca90c011e9af33f..ce0b4a2d191b23e3b3022ba163696611b147d229 100755 (executable)
@@ -181,6 +181,13 @@ describe firewall do
     end
   end
 
+  describe 'port deprecated' do
+    it "raises a warning" do
+      expect(Puppet).to receive(:warning).with /port is deprecated/
+      @resource[:port] = "22"
+    end
+  end
+
   [:dst_type, :src_type].each do |addrtype|
     describe addrtype do
       it "should have no default" do