Shared folders marked with `:disabled` flag will be ignored.

This commit is contained in:
Mitchell Hashimoto 2010-07-14 22:53:24 -07:00
parent a5643d3239
commit 245ada2441
5 changed files with 25 additions and 10 deletions

View File

@ -63,14 +63,13 @@ module Vagrant
# Load the NFS enabled shared folders
@folders = @env["config"].vm.shared_folders.inject({}) do |acc, data|
key, opts = data
acc[key] = opts if opts[:nfs]
acc
end
# Delete them from the original configuration so they aren't
# mounted by the ShareFolders middleware
@folders.each do |key, opts|
@env["config"].vm.shared_folders.delete(key)
if opts[:nfs]
acc[key] = opts.dup
opts[:disabled] = true
end
acc
end
end

View File

@ -32,6 +32,8 @@ module Vagrant
@env.env.config.vm.shared_folders.inject({}) do |acc, data|
key, value = data
return acc if value[:disabled]
# This to prevent overwriting the actual shared folders data
value = value.dup

View File

@ -19,6 +19,10 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
end
context "checking for threshold" do
setup do
@klass.any_instance.stubs(:external_collision_check)
end
should "error if has a port below threshold" do
@env.env.config.vm.forwarded_ports.clear
@env.env.config.vm.forward_port("foo", 22, 222)

View File

@ -93,6 +93,7 @@ class NFSVMActionTest < Test::Unit::TestCase
context "extracting folders" do
setup do
@env.env.config.vm.shared_folders.clear
@env.env.config.vm.share_folder("v-foo", "/foo", ".", :nfs => true)
@env.env.config.vm.share_folder("v-bar", "/bar", ".", :nfs => true)
end
@ -102,10 +103,11 @@ class NFSVMActionTest < Test::Unit::TestCase
assert_equal 2, @instance.folders.length
end
should "remove the folders from the original config" do
should "mark the folders disabled from the original config" do
@instance.extract_folders
assert_equal 1, @env["config"].vm.shared_folders.length
assert @env["config"].vm.shared_folders.has_key?("v-root")
%W[v-foo v-bar].each do |key|
assert @env["config"].vm.shared_folders[key][:disabled]
end
end
end

View File

@ -85,6 +85,14 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase
end
end
should "ignore disabled shared folders" do
stub_shared_folders do |config|
config.vm.share_folder("v-root", "/vagrant", ".", :disabled => true)
end
assert @instance.shared_folders.empty?
end
should "append sync suffix if sync enabled to a folder" do
name = "foo"
guest = "bar"