Change the way the config is loaded to be all in one step
This commit is contained in:
parent
ce9ff73ea4
commit
52a32820db
|
@ -206,9 +206,6 @@ module Vagrant
|
|||
@loaded = true
|
||||
self.class.check_virtualbox!
|
||||
load_config!
|
||||
load_home_directory!
|
||||
load_box!
|
||||
load_config!
|
||||
load_vm!
|
||||
self
|
||||
end
|
||||
|
@ -218,24 +215,36 @@ module Vagrant
|
|||
# this environment, meaning that it will use the given root directory
|
||||
# to load the Vagrantfile into that context.
|
||||
def load_config!
|
||||
first_run = @config.nil?
|
||||
|
||||
# First load the initial, non config-dependent Vagrantfiles
|
||||
loader = Config.new(self)
|
||||
loader.queue << File.expand_path("config/default.rb", Vagrant.source_root)
|
||||
loader.queue << File.join(box.directory, ROOTFILE_NAME) if box
|
||||
loader.queue << File.join(home_path, ROOTFILE_NAME) if home_path
|
||||
loader.queue << File.join(box.directory, ROOTFILE_NAME) if !first_run && box
|
||||
loader.queue << File.join(home_path, ROOTFILE_NAME) if !first_run && home_path
|
||||
loader.queue << File.join(root_path, ROOTFILE_NAME) if root_path
|
||||
|
||||
# If this environment represents some VM in a multi-VM environment,
|
||||
# we push that VM's configuration onto the config_queue.
|
||||
if vm_name
|
||||
# If this environment is representing a sub-VM, then we push that
|
||||
# proc on as the last configuration.
|
||||
if !first_run && vm_name
|
||||
subvm = parent.config.vm.defined_vms[vm_name]
|
||||
loader.queue << subvm.proc_stack if subvm
|
||||
end
|
||||
|
||||
# Execute the configuration stack and store the result
|
||||
# Execute the configuration stack and store the result as the final
|
||||
# value in the config ivar.
|
||||
@config = loader.load!
|
||||
|
||||
# (re)load the logger
|
||||
@logger = nil
|
||||
|
||||
if first_run
|
||||
# After the first run we want to load the configuration again since
|
||||
# it can change due to box Vagrantfiles and home directory Vagrantfiles
|
||||
load_home_directory!
|
||||
load_box!
|
||||
load_config!
|
||||
end
|
||||
end
|
||||
|
||||
# Loads the home directory path and creates the necessary subdirectories
|
||||
|
@ -256,8 +265,6 @@ module Vagrant
|
|||
|
||||
# Loads the specified box for this environment.
|
||||
def load_box!
|
||||
return unless root_path
|
||||
|
||||
@box = Box.find(self, config.vm.box) if config.vm.box
|
||||
end
|
||||
|
||||
|
|
|
@ -318,9 +318,6 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
call_seq = sequence("call_sequence")
|
||||
@klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
|
||||
@env.expects(:load_config!).once.in_sequence(call_seq)
|
||||
@env.expects(:load_home_directory!).once.in_sequence(call_seq)
|
||||
@env.expects(:load_box!).once.in_sequence(call_seq)
|
||||
@env.expects(:load_config!).once.in_sequence(call_seq)
|
||||
@env.expects(:load_vm!).once.in_sequence(call_seq)
|
||||
assert_equal @env, @env.load!
|
||||
end
|
||||
|
@ -333,6 +330,10 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
@env.stubs(:root_path).returns(@root_path)
|
||||
@env.stubs(:home_path).returns(@home_path)
|
||||
|
||||
# Temporary
|
||||
@env.stubs(:load_home_directory!)
|
||||
@env.stubs(:load_box!)
|
||||
|
||||
@loader = Vagrant::Config.new(@env)
|
||||
Vagrant::Config.stubs(:new).returns(@loader)
|
||||
@loader.stubs(:load!)
|
||||
|
@ -388,7 +389,7 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
|
||||
should "execute after loading and set result to environment config" do
|
||||
result = mock("result")
|
||||
@loader.expects(:load!).once.returns(result)
|
||||
@loader.stubs(:load!).returns(result)
|
||||
@env.load_config!
|
||||
assert_equal result, @env.config
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue