2014-03-26 23:45:46 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module DockerProvider
|
|
|
|
module Action
|
|
|
|
class Destroy
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2014-04-11 01:26:19 +00:00
|
|
|
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
2014-03-26 23:45:46 +00:00
|
|
|
|
|
|
|
machine = env[:machine]
|
|
|
|
driver = machine.provider.driver
|
|
|
|
|
2014-04-19 00:19:31 +00:00
|
|
|
# If we have a build image, store that
|
|
|
|
image_file = machine.data_dir.join("docker_build_image")
|
|
|
|
image = nil
|
|
|
|
if image_file.file?
|
|
|
|
image = image_file.read.chomp
|
|
|
|
end
|
|
|
|
env[:build_image] = image
|
|
|
|
|
2014-03-26 23:45:46 +00:00
|
|
|
driver.rm(machine.id)
|
|
|
|
machine.id = nil
|
|
|
|
|
2014-04-19 00:19:31 +00:00
|
|
|
@app.call(env)
|
2014-03-26 23:45:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|