synced_folder: Support for mount_options
This commit is contained in:
parent
623eb1570a
commit
20d4547044
3 changed files with 16 additions and 6 deletions
|
@ -61,12 +61,12 @@ module Vagrant
|
|||
end
|
||||
|
||||
def share_folders(folders)
|
||||
folders.each do |folder|
|
||||
share_folder(folder[:hostpath], folder[:guestpath])
|
||||
folders.each do |f|
|
||||
share_folder(f[:hostpath], f[:guestpath], f.fetch(:mount_options, 'bind'))
|
||||
end
|
||||
end
|
||||
|
||||
def share_folder(host_path, guest_path)
|
||||
def share_folder(host_path, guest_path, mount_options = ['bind'])
|
||||
guest_path = rootfs_path.join(guest_path.gsub(/^\//, ''))
|
||||
unless guest_path.directory?
|
||||
begin
|
||||
|
@ -77,7 +77,8 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
@customizations << ['mount.entry', "#{host_path} #{guest_path} none bind 0 0"]
|
||||
mount_options = Array(mount_options)
|
||||
@customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"]
|
||||
end
|
||||
|
||||
def start(customizations)
|
||||
|
|
|
@ -25,7 +25,8 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
machine.provider.driver.share_folder(host_path, guest_path)
|
||||
mount_opts = data[:mount_options]
|
||||
machine.provider.driver.share_folder(host_path, guest_path, mount_opts)
|
||||
# Guest path specified, so mount the folder to specified point
|
||||
machine.ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
|
||||
guestpath: data[:guestpath],
|
||||
|
|
|
@ -140,7 +140,8 @@ describe Vagrant::LXC::Driver do
|
|||
|
||||
describe 'folder sharing' do
|
||||
let(:shared_folder) { {guestpath: '/vagrant', hostpath: '/path/to/host/dir'} }
|
||||
let(:folders) { [shared_folder] }
|
||||
let(:ro_rw_folder) { {guestpath: '/vagrant/ro_rw', hostpath: '/path/to/host/dir', mount_options: ['ro', 'rw']} }
|
||||
let(:folders) { [shared_folder, ro_rw_folder] }
|
||||
let(:rootfs_path) { Pathname('/path/to/rootfs') }
|
||||
let(:expected_guest_path) { "#{rootfs_path}/vagrant" }
|
||||
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
|
||||
|
@ -162,5 +163,12 @@ describe Vagrant::LXC::Driver do
|
|||
"#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0"
|
||||
]
|
||||
end
|
||||
|
||||
it 'supports additional mount options' do
|
||||
subject.customizations.should include [
|
||||
'mount.entry',
|
||||
"#{ro_rw_folder[:hostpath]} #{rootfs_path}/vagrant/ro_rw none ro,rw 0 0"
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue