From cccbedf4cea0ec8e8ee2b601ec6d7ca40abd2b71 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 4 Mar 2019 14:19:40 -0800 Subject: [PATCH] Update how docker network handles processing options to cli arguments Add an "ignored option" array rather than a big if-statement expression --- plugins/providers/docker/action/network.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/providers/docker/action/network.rb b/plugins/providers/docker/action/network.rb index de5afca57..d95a14ab1 100644 --- a/plugins/providers/docker/action/network.rb +++ b/plugins/providers/docker/action/network.rb @@ -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