Get rid of more references to Vagrant.config. Only one remains.

This commit is contained in:
Mitchell Hashimoto 2010-05-07 22:57:25 -07:00
parent b1b4ae2077
commit af383e222a
4 changed files with 18 additions and 20 deletions

View File

@ -26,7 +26,7 @@ module Vagrant
def clone_and_attach
logger.info "Cloning current VM Disk to new location (#{new_image_path})..."
hard_drive.image = hard_drive.image.clone(new_image_path, Vagrant.config.vm.disk_image_format, true)
hard_drive.image = hard_drive.image.clone(new_image_path, @runner.env.config.vm.disk_image_format, true)
logger.info "Attaching new disk to VM ..."
@runner.vm.save
@ -43,7 +43,7 @@ module Vagrant
# Returns the path to the new location for the hard drive
def new_image_path
File.join(Vagrant.config.vm.hd_location, hard_drive.image.filename)
File.join(@runner.env.config.vm.hd_location, hard_drive.image.filename)
end
end
end

View File

@ -29,10 +29,12 @@ module Vagrant
push_proc(&block)
end
def execute!
run_procs!(config)
config.loaded!
config
def execute!(config_object=nil)
config_object ||= config
run_procs!(config_object)
config_object.loaded!
config_object
end
end
end

View File

@ -6,7 +6,7 @@ module Vagrant
attr_reader :system
attr_accessor :vm
class << self
class <<self
# Finds a virtual machine by a given UUID and either returns
# a Vagrant::VM object or returns nil.
def find(uuid, env=nil)

View File

@ -52,17 +52,6 @@ class ConfigTest < Test::Unit::TestCase
end
end
context "accessing configuration" do
setup do
Vagrant::Config.run { |config| }
Vagrant::Config.execute!
end
should "forward config to the class method" do
assert_equal Vagrant.config, Vagrant::Config.config
end
end
context "initializing" do
setup do
Vagrant::Config.reset!
@ -92,7 +81,14 @@ class ConfigTest < Test::Unit::TestCase
should "return the configuration on execute!" do
Vagrant::Config.run {}
result = Vagrant::Config.execute!
assert result.equal?(Vagrant.config)
assert result.is_a?(Vagrant::Config::Top)
end
should "use given configuration object if given" do
fake_env = mock("env")
config = Vagrant::Config::Top.new(fake_env)
result = Vagrant::Config.execute!(config)
assert_equal config.env, result.env
end
end