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-05-06 04:37:02 +00:00
|
|
|
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
2014-05-06 04:35:08 +00:00
|
|
|
|
2014-05-06 04:37:02 +00:00
|
|
|
machine = env[:machine]
|
|
|
|
driver = machine.provider.driver
|
2014-05-06 04:35:08 +00:00
|
|
|
|
2014-05-06 04:37:02 +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
|
2014-04-19 00:19:31 +00:00
|
|
|
end
|
2014-05-06 04:37:02 +00:00
|
|
|
env[:build_image] = image
|
2014-04-19 00:19:31 +00:00
|
|
|
|
2014-05-06 04:37:02 +00:00
|
|
|
driver.rm(machine.id)
|
2014-03-26 23:45:46 +00:00
|
|
|
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
|