`vagrant package` now uses the environment
This commit is contained in:
parent
0641df7563
commit
fddee1158d
|
@ -21,14 +21,14 @@ module Vagrant
|
|||
end
|
||||
|
||||
def setup_temp_dir
|
||||
@temp_dir = File.join(Env.tmp_path, Time.now.to_i.to_s)
|
||||
@temp_dir = File.join(@runner.env.tmp_path, Time.now.to_i.to_s)
|
||||
|
||||
logger.info "Creating temporary directory for export..."
|
||||
FileUtils.mkpath(temp_dir)
|
||||
end
|
||||
|
||||
def ovf_path
|
||||
File.join(temp_dir, Vagrant.config.vm.box_ovf)
|
||||
File.join(temp_dir, @runner.env.config.vm.box_ovf)
|
||||
end
|
||||
|
||||
def export
|
||||
|
|
|
@ -29,7 +29,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def tar_path
|
||||
File.join(FileUtils.pwd, "#{out_path}#{Vagrant.config.package.extension}")
|
||||
File.join(FileUtils.pwd, "#{out_path}#{@runner.env.config.package.extension}")
|
||||
end
|
||||
|
||||
def temp_path
|
||||
|
|
|
@ -157,11 +157,11 @@ msg
|
|||
#
|
||||
# This command requires that an instance be powered off
|
||||
def package(out_path=nil, include_files=[])
|
||||
Env.load!
|
||||
Env.require_persisted_vm
|
||||
error_and_exit(:vm_power_off_to_package) unless Env.persisted_vm.powered_off?
|
||||
env = Environment.load!
|
||||
env.require_persisted_vm
|
||||
error_and_exit(:vm_power_off_to_package) unless env.vm.powered_off?
|
||||
|
||||
Env.persisted_vm.package(out_path, include_files)
|
||||
env.vm.package(out_path, include_files)
|
||||
end
|
||||
|
||||
# Manages the `vagrant box` command, allowing the user to add
|
||||
|
|
|
@ -70,6 +70,11 @@ module Vagrant
|
|||
config ? config.vagrant.home : nil
|
||||
end
|
||||
|
||||
# The path to the Vagrant tmp directory
|
||||
def tmp_path
|
||||
File.join(home_path, "tmp")
|
||||
end
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Load Methods
|
||||
#---------------------------------------------------------------
|
||||
|
|
|
@ -21,9 +21,9 @@ class ExportActionTest < Test::Unit::TestCase
|
|||
Time.stubs(:now).returns(@time_now)
|
||||
|
||||
@tmp_path = "foo"
|
||||
Vagrant::Env.stubs(:tmp_path).returns(@tmp_path)
|
||||
@runner.env.stubs(:tmp_path).returns(@tmp_path)
|
||||
|
||||
@temp_dir = File.join(Vagrant::Env.tmp_path, @time_now)
|
||||
@temp_dir = File.join(@runner.env.tmp_path, @time_now)
|
||||
FileUtils.stubs(:mkpath)
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ExportActionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "be the temporary directory joined with the OVF filename" do
|
||||
assert_equal File.join(@temp_dir, Vagrant.config.vm.box_ovf), @action.ovf_path
|
||||
assert_equal File.join(@temp_dir, @runner.env.config.vm.box_ovf), @action.ovf_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
should "be the temporary directory with the name and extension attached" do
|
||||
pwd = "foo"
|
||||
FileUtils.stubs(:pwd).returns(pwd)
|
||||
assert_equal File.join(pwd, "#{@action.out_path}#{Vagrant.config.package.extension}"), @action.tar_path
|
||||
assert_equal File.join(pwd, "#{@action.out_path}#{@runner.env.config.package.extension}"), @action.tar_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -211,8 +211,13 @@ class CommandsTest < Test::Unit::TestCase
|
|||
@persisted_vm.stubs(:powered_off?).returns(true)
|
||||
end
|
||||
|
||||
should "load the current environment" do
|
||||
Vagrant::Environment.expects(:load!).once.returns(@env)
|
||||
Vagrant::Commands.package
|
||||
end
|
||||
|
||||
should "require a persisted vm" do
|
||||
Vagrant::Env.expects(:require_persisted_vm).once
|
||||
@env.expects(:require_persisted_vm).once
|
||||
Vagrant::Commands.package
|
||||
end
|
||||
|
||||
|
|
|
@ -111,6 +111,14 @@ class EnvironmentTest < Test::Unit::TestCase
|
|||
assert_equal @env.config.vagrant.home, @env.home_path
|
||||
end
|
||||
end
|
||||
|
||||
context "temp path" do
|
||||
should "return the home path joined with 'tmp'" do
|
||||
home_path = "foo"
|
||||
@env.stubs(:home_path).returns(home_path)
|
||||
assert_equal File.join("foo", "tmp"), @env.tmp_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "loading" do
|
||||
|
|
Loading…
Reference in New Issue