Ensure tmp dir for validate is removed once command exits
This commit is contained in:
parent
69eacd2b73
commit
5fa3c5866c
|
@ -30,7 +30,7 @@ module VagrantPlugins
|
||||||
action_env = {}
|
action_env = {}
|
||||||
if options[:ignore_provider]
|
if options[:ignore_provider]
|
||||||
action_env[:ignore_provider] = true
|
action_env[:ignore_provider] = true
|
||||||
mockup_providers!
|
tmp_data_dir = mockup_providers!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validate the configuration of all machines
|
# Validate the configuration of all machines
|
||||||
|
@ -42,6 +42,8 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Success, exit status 0
|
# Success, exit status 0
|
||||||
0
|
0
|
||||||
|
ensure
|
||||||
|
FileUtils.remove_entry tmp_data_dir if tmp_data_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -51,6 +53,8 @@ module VagrantPlugins
|
||||||
# It essentially ignores that there are no installed or usable prodivers so
|
# It essentially ignores that there are no installed or usable prodivers so
|
||||||
# that Vagrant can go along and validate the rest of the Vagrantfile and ignore
|
# that Vagrant can go along and validate the rest of the Vagrantfile and ignore
|
||||||
# any provider blocks.
|
# any provider blocks.
|
||||||
|
#
|
||||||
|
# return [String] tmp_data_dir - Temporary dir used to store guest metadata during validation
|
||||||
def mockup_providers!
|
def mockup_providers!
|
||||||
require 'log4r'
|
require 'log4r'
|
||||||
logger = Log4r::Logger.new("vagrant::validate")
|
logger = Log4r::Logger.new("vagrant::validate")
|
||||||
|
@ -93,6 +97,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
tmp_data_dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -138,7 +138,8 @@ describe VagrantPlugins::CommandValidate::Command do
|
||||||
VF
|
VF
|
||||||
end
|
end
|
||||||
it "ignores provider specific configurations with the flag" do
|
it "ignores provider specific configurations with the flag" do
|
||||||
allow(subject).to receive(:mockup_providers!).and_return(true)
|
allow(subject).to receive(:mockup_providers!).and_return("")
|
||||||
|
allow(FileUtils).to receive(:remove_entry).and_return(true)
|
||||||
expect(iso_env.ui).to receive(:info).with(any_args) { |message, _|
|
expect(iso_env.ui).to receive(:info).with(any_args) { |message, _|
|
||||||
expect(message).to include("Vagrantfile validated successfully.")
|
expect(message).to include("Vagrantfile validated successfully.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue