providers/docker: less hack way to clear ID if not created
This commit is contained in:
parent
b26ecb0150
commit
ff2f035f27
|
@ -143,7 +143,6 @@ module VagrantPlugins
|
||||||
b.use Call, IsState, :not_created do |env, b2|
|
b.use Call, IsState, :not_created do |env, b2|
|
||||||
if env[:result]
|
if env[:result]
|
||||||
b2.use Message, I18n.t("docker_provider.messages.not_created")
|
b2.use Message, I18n.t("docker_provider.messages.not_created")
|
||||||
b2.use Destroy
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,25 +7,20 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
||||||
|
|
||||||
machine = env[:machine]
|
machine = env[:machine]
|
||||||
|
driver = machine.provider.driver
|
||||||
|
|
||||||
# If the container actually exists, destroy it
|
# If we have a build image, store that
|
||||||
if machine.state.id != :not_created
|
image_file = machine.data_dir.join("docker_build_image")
|
||||||
driver = machine.provider.driver
|
image = nil
|
||||||
|
if image_file.file?
|
||||||
# If we have a build image, store that
|
image = image_file.read.chomp
|
||||||
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
|
|
||||||
|
|
||||||
env[:ui].info I18n.t("docker_provider.messages.destroying")
|
|
||||||
driver.rm(machine.id)
|
|
||||||
end
|
end
|
||||||
|
env[:build_image] = image
|
||||||
|
|
||||||
# Otherwise, always make sure we remove the ID
|
driver.rm(machine.id)
|
||||||
machine.id = nil
|
machine.id = nil
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -146,6 +146,9 @@ module VagrantPlugins
|
||||||
state_id = driver.state(@machine.id) if @machine.id && !state_id
|
state_id = driver.state(@machine.id) if @machine.id && !state_id
|
||||||
state_id = :unknown if !state_id
|
state_id = :unknown if !state_id
|
||||||
|
|
||||||
|
# If the machine is not created, make sure to clear out machine ID
|
||||||
|
@machine.id = nil if state_id == :not_created
|
||||||
|
|
||||||
short = state_id.to_s.gsub("_", " ")
|
short = state_id.to_s.gsub("_", " ")
|
||||||
long = I18n.t("docker_provider.status.#{state_id}")
|
long = I18n.t("docker_provider.status.#{state_id}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue