Skip to content

Commit

Permalink
(network-#26) Loosen regex on interfaces provider
Browse files Browse the repository at this point in the history
Given a Debian interfaces file if an `iface` line had two spaces between
iface and the network device the file would be marked as invalid. This
commit removes the single whitespace restriction.

This closes #26.
  • Loading branch information
adrienthebo committed Feb 27, 2013
1 parent eefcec3 commit b614878
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/network_config/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def self.parse_file(filename, contents)
# iface <iface> <family> <method>
# zero or more options for <iface>

if match = line.match(/^iface (\S+)\s+(\S+)\s+(\S+)/)
if match = line.match(/^iface\s+(\S+)\s+(\S+)\s+(\S+)/)
name = match[1]
family = match[2]
method = match[3]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
12 changes: 12 additions & 0 deletions spec/unit/provider/network_config/interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def fixture_data(file)
}
end

it "should ignore variable whitespace in iface lines (network-#26)" do
fixture = fixture_data('iface_whitespace')
data = described_class.parse_file('', fixture)
data.find { |h| h[:name] == "eth0" }.should == {
:family => "inet",
:method => "dhcp",
:name => "eth0",
:hotplug => true,
:options => {},
}
end

it "should parse out lines following iface lines" do
fixture = fixture_data('single_interface_static')
data = described_class.parse_file('', fixture)
Expand Down

0 comments on commit b614878

Please sign in to comment.