guests/linux: Update constant name, freeze constant values

This commit is contained in:
Chris Roberts 2016-09-30 12:11:54 -07:00
parent 9f468d2626
commit 0300df09fb
2 changed files with 3 additions and 4 deletions

View File

@ -5,7 +5,7 @@ module VagrantPlugins
# Valid ethernet device prefix values.
# eth - classic prefix
# en - predictable interface names prefix
ETHERNET_PREFIX = ["eth", "en"]
POSSIBLE_ETHERNET_PREFIXES = ["eth".freeze, "en".freeze].freeze
@@logger = Log4r::Logger.new("vagrant::guest::linux::network_interfaces")
@ -25,8 +25,8 @@ module VagrantPlugins
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
ifaces = ifaces.map do |iface|
unless eth_prefix
eth_prefix = ETHERNET_PREFIX.detect do |prefix|
if eth_prefix.nil?
eth_prefix = POSSIBLE_ETHERNET_PREFIXES.detect do |prefix|
iface.start_with?(prefix)
end
end

View File

@ -56,6 +56,5 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
result = cap.network_interfaces(machine)
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"])
end
end
end