Update how docker network handles processing options to cli arguments

Add an "ignored option" array rather than a big if-statement expression
This commit is contained in:
Brian Cain 2019-03-04 14:19:40 -08:00
parent 953a380371
commit cccbedf4ce
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 6 additions and 2 deletions

View File

@ -13,12 +13,12 @@ module VagrantPlugins
# @returns[Array] cli_opts - an array of strings used for the network commnad
def generate_create_cli_arguments(options)
cli_opts = []
ignored_options = ["ip", "protocol", "id", "alias"]
# Splits the networking options to generate the proper CLI flags for docker
options.each do |opt, value|
opt = opt.to_s
if opt == "ip" || (opt == "type" && value == "dhcp") ||
opt == "protocol" || opt == "id"
if (opt == "type" && value == "dhcp") || ignored_options.include?(opt)
# `docker network create` doesn't care about these options
next
else
@ -40,6 +40,10 @@ module VagrantPlugins
cli_opts = ["--ip6", options[:ip6]]
end
if options[:alias]
cli_opts.concat(["--alias=#{options[:alias]}"])
end
return cli_opts
end