From c1be64ae61f94c91d0d6f721f5060ba14e69db9a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 31 Dec 2010 02:19:18 -0600 Subject: [PATCH] Shared folders with no guest path are not automounted [closes GH-184] --- CHANGELOG.md | 1 + lib/vagrant/action/vm/share_folders.rb | 15 +++++++++++---- templates/locales/en.yml | 1 + test/vagrant/action/vm/share_folders_test.rb | 7 ++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70426ceae..e1e13b419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Use numeric uid/gid in mounting shared folders to increase portability. [GH-252] - HTTP downloading follows redirects. [GH-163] - Downloaders have clearer output to note what they're doing. + - Shared folders with no guest path are not automounted. [GH-184] ## 0.7.0.beta (December 24, 2010) diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 36bd451a6..197334607 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -50,10 +50,17 @@ module Vagrant @env["vm"].ssh.execute do |ssh| shared_folders.each do |name, data| - @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", - :name => name, - :guest_path => data[:guestpath])) - @env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath]) + if data[:guestpath] + # Guest path specified, so mount the folder to specified point + @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", + :name => name, + :guest_path => data[:guestpath])) + @env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath]) + else + # If no guest path is specified, then automounting is disabled + @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", + :name => name)) + end end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 6c0e13e5f..aedcfef98 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -361,6 +361,7 @@ en: creating: Creating shared folders metadata... mounting: Mounting shared folders... mounting_entry: "-- %{name}: %{guest_path}" + nomount_entry: "-- %{name}: Automounting disabled." suspend: suspending: Saving VM state and suspending execution... diff --git a/test/vagrant/action/vm/share_folders_test.rb b/test/vagrant/action/vm/share_folders_test.rb index d33b6f49d..9b9de8878 100644 --- a/test/vagrant/action/vm/share_folders_test.rb +++ b/test/vagrant/action/vm/share_folders_test.rb @@ -116,6 +116,7 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase @folders = stub_shared_folders(<<-sf) config.vm.share_folder("foo", "fooguest", "foohost") config.vm.share_folder("bar", "barguest", "barhost") + config.vm.share_folder("foo_no_mount", nil, "foohost2") sf @ssh = mock("ssh") @vm.ssh.stubs(:execute).yields(@ssh) @@ -125,7 +126,11 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase should "mount all shared folders to the VM" do mount_seq = sequence("mount_seq") @folders.each do |name, data| - @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq) + if data[:guestpath] + @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq) + else + @vm.system.expects(:mount_shared_folder).with(@ssh, name, anything).never + end end @instance.mount_shared_folders