Don't error if box doesn't exist on load
This commit is contained in:
parent
a4713d5a84
commit
819140bbc2
|
@ -181,13 +181,18 @@ module Vagrant
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
box_vagrantfile = find_vagrantfile(box.directory)
|
# If a box was found, then we attempt to load the Vagrantfile for
|
||||||
if box_vagrantfile
|
# that box. We don't require a box since we allow providers to download
|
||||||
# The box has a custom Vagrantfile, so we load that into the config
|
# boxes and so on.
|
||||||
# as well.
|
if box
|
||||||
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
box_vagrantfile = find_vagrantfile(box.directory)
|
||||||
@config_loader.set(box_config_key, box_vagrantfile)
|
if box_vagrantfile
|
||||||
config = @config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
# The box has a custom Vagrantfile, so we load that into the config
|
||||||
|
# as well.
|
||||||
|
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
||||||
|
@config_loader.set(box_config_key, box_vagrantfile)
|
||||||
|
config = @config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create the machine and cache it for future calls. This will also
|
# Create the machine and cache it for future calls. This will also
|
||||||
|
|
|
@ -235,6 +235,22 @@ VF
|
||||||
vm2_foo.should eql(env.machine(:vm2, :foo))
|
vm2_foo.should eql(env.machine(:vm2, :foo))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should load a machine without a box" do
|
||||||
|
register_provider("foo")
|
||||||
|
|
||||||
|
environment = isolated_environment do |env|
|
||||||
|
env.vagrantfile(<<-VF)
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "i-dont-exist"
|
||||||
|
end
|
||||||
|
VF
|
||||||
|
end
|
||||||
|
|
||||||
|
env = environment.create_vagrant_env
|
||||||
|
machine = env.machine(:default, :foo)
|
||||||
|
machine.box.should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
it "should load the machine configuration" do
|
it "should load the machine configuration" do
|
||||||
register_provider("foo")
|
register_provider("foo")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue