From 349cc5ddac1c377ba5f93dfadde45f80992c4000 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 26 Feb 2019 11:46:00 -0800 Subject: [PATCH] Add placeholder network destroy action for docker --- .../docker/action/destroy_network.rb | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plugins/providers/docker/action/destroy_network.rb diff --git a/plugins/providers/docker/action/destroy_network.rb b/plugins/providers/docker/action/destroy_network.rb new file mode 100644 index 000000000..e45a558b3 --- /dev/null +++ b/plugins/providers/docker/action/destroy_network.rb @@ -0,0 +1,33 @@ +require 'log4r' + +module VagrantPlugins + module DockerProvider + module Action + class DestroyNetwork + def initialize(app, env) + @app = app + @logger = Log4r::Logger.new('vagrant::plugins::docker::network') + end + + def call(env) + # If we are using a host VM, then don't worry about it + machine = env[:machine] + if machine.provider.host_vm? + @logger.debug("Not setting up networks because docker host_vm is in use") + return @app.call(env) + end + + machine.config.vm.networks.each do |type, options| + # We only handle private and public networks + next if type != :private_network && type != :public_network + + # If network is defined in machines config as isolated single container network, then delete + # If it's custom and or default, check if other containers are using it, and if not, delete + end + + @app.call(env) + end + end + end + end +end