Download the box specified by the URL if it doesn't yet exist [closes GH-113]
Thanks a lot to Vitor Pellegrino for much of the work on this.
This commit is contained in:
parent
0e1a304cb8
commit
f472dbde44
|
@ -15,6 +15,8 @@ module Vagrant
|
||||||
return env.error!(:box_specified_doesnt_exist, :box_name => box_name) if !box_url
|
return env.error!(:box_specified_doesnt_exist, :box_name => box_name) if !box_url
|
||||||
|
|
||||||
env.logger.info "Box #{box_name} not found. Fetching box since URL specified..."
|
env.logger.info "Box #{box_name} not found. Fetching box since URL specified..."
|
||||||
|
Vagrant::Box.add(env.env, box_name, box_url)
|
||||||
|
env.env.load_box!
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Test::Unit::TestCase
|
||||||
config.ssh.private_key_path = '~/foo'
|
config.ssh.private_key_path = '~/foo'
|
||||||
|
|
||||||
config.vm.box = "foo"
|
config.vm.box = "foo"
|
||||||
config.vm.box_url = "http://mycompany.com/protected/my_box.box"
|
config.vm.box_url = nil
|
||||||
config.vm.box_ovf = "box.ovf"
|
config.vm.box_ovf = "box.ovf"
|
||||||
config.vm.base_mac = "42"
|
config.vm.base_mac = "42"
|
||||||
config.vm.disk_image_format = 'VMDK'
|
config.vm.disk_image_format = 'VMDK'
|
||||||
|
|
|
@ -32,5 +32,17 @@ class CheckBoxVMActionTest < Test::Unit::TestCase
|
||||||
assert @env.error?
|
assert @env.error?
|
||||||
assert_equal :box_specified_doesnt_exist, @env.error.first
|
assert_equal :box_specified_doesnt_exist, @env.error.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "attempt to download box and continue if URL specified" do
|
||||||
|
seq = sequence("seq")
|
||||||
|
@env.env.config.vm.box_url = "bar"
|
||||||
|
Vagrant::Box.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.expects(:load_box!).in_sequence(seq)
|
||||||
|
@app.expects(:call).with(@env).once.in_sequence(seq)
|
||||||
|
|
||||||
|
@instance.call(@env)
|
||||||
|
assert !@env.error?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue