Reload config after downloading box during `up` [closes GH-231]

This commit is contained in:
Mitchell Hashimoto 2010-12-31 21:41:05 -06:00
parent e12d96d4df
commit fb8f0c010b
5 changed files with 26 additions and 0 deletions

View File

@ -4,6 +4,8 @@
- HTTP downloading follows redirects. [GH-163]
- Downloaders have clearer output to note what they're doing.
- Shared folders with no guest path are not automounted. [GH-184]
- Boxes downloaded during `vagrant up` reload the Vagrantfile config, which
fixes a problem with box settings not being properly loaded. [GH-231]
## 0.7.0.beta (December 24, 2010)

View File

@ -17,6 +17,7 @@ module Vagrant
env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
Vagrant::Box.add(env.env, box_name, box_url)
env["boxes"].reload!
env.env.reload_config!
end
@app.call(env)

View File

@ -305,6 +305,13 @@ module Vagrant
self
end
# Reloads the configuration of this environment.
def reload_config!
@config = nil
load_config!
self
end
# Loads this environment's configuration and stores it in the {#config}
# variable. The configuration loaded by this method is specified to
# this environment, meaning that it will use the given root directory

View File

@ -45,6 +45,7 @@ class CheckBoxVMActionTest < Test::Unit::TestCase
env.env.boxes.expects(:find).returns(nil)
Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq)
env.env.boxes.expects(:reload!).in_sequence(seq)
env.env.expects(:reload_config!).in_sequence(seq)
app.expects(:call).with(env).once.in_sequence(seq)
assert_nothing_raised {

View File

@ -425,6 +425,21 @@ class EnvironmentTest < Test::Unit::TestCase
@env.load_config!
assert @env.instance_variable_get(:@logger).nil?
end
should "be able to reload config" do
vagrantfile(@env.root_path, "config.vm.box = 'box'")
# First load the config normally
@env.load_config!
assert_equal "box", @env.config.vm.box
assert_not_equal "set", @env.config.vm.base_mac
# Modify the Vagrantfile and reload it, then verify new results
# are available
vagrantfile(@env.root_path, "config.vm.base_mac = 'set'")
@env.reload_config!
assert_equal "set", @env.config.vm.base_mac
end
end
context "loading home directory" do