Skip to content

Commit 52c9500

Browse files
committed
Deprecate port parameter
I couldn't find any valid use case for port, and if any valid case did exist then sport+dport could be used.
1 parent 7281b0a commit 52c9500

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

README.markdown

-2
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,6 @@ firewall { '999 this runs last':
621621

622622
* `pkttype`: Sets the packet type to match. Valid values are: 'unicast', 'broadcast', and'multicast'. Requires the `pkttype` feature.
623623

624-
* `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.
625-
626624
* `proto`: The specific protocol to match for this rule. This is 'tcp' by default. Valid values are:
627625
* 'tcp'
628626
* 'udp'

lib/puppet/type/firewall.rb

+5-12
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,13 @@ def should_to_s(value)
272272

273273
newproperty(:port, :array_matching => :all) do
274274
desc <<-EOS
275-
The destination or source port to match for this filter (if the protocol
276-
supports ports). Will accept a single element or an array.
277-
278-
For some firewall providers you can pass a range of ports in the format:
279-
280-
<start_number>-<ending_number>
281-
282-
For example:
283-
284-
1-1024
285-
286-
This would cover ports 1 to 1024.
275+
DEPRECATED
287276
EOS
288277

278+
validate do |value|
279+
Puppet.warning("port is deprecated and will be removed. Use dport and/or sport instead.")
280+
end
281+
289282
munge do |value|
290283
@resource.string_to_port(value, :proto)
291284
end

spec/fixtures/iptables/conversion_hash.rb

-8
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,6 @@
775775
},
776776
:args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '000 allow symbols ( $+<=>^`|~ ) in ruby >= 1.9'],
777777
},
778-
'port_property' => {
779-
:params => {
780-
:name => '001 port property',
781-
:table => 'filter',
782-
:port => '80',
783-
},
784-
:args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--ports', '80', '-m', 'comment', '--comment', '001 port property'],
785-
},
786778
'log_level_debug' => {
787779
:params => {
788780
:name => '956 INPUT log-level',

spec/unit/puppet/type/firewall_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@
181181
end
182182
end
183183

184+
describe 'port deprecated' do
185+
it "raises a deprecation warning" do
186+
expect(Puppet).to receive(:deprecation_warning).with /port is deprecated/
187+
@resource[:port] = "22"
188+
end
189+
end
190+
184191
[:dst_type, :src_type].each do |addrtype|
185192
describe addrtype do
186193
it "should have no default" do

0 commit comments

Comments
 (0)