mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Replace 9p synced folder :owner with :access (#1571)
The 9p synced folder option :owner is better named as :access, which is documented by 9p and less likely to cause confusion on the expected behaviour as it does not control the owner of the files. Relates-To: #378
This commit is contained in:
parent
0af8931c36
commit
997fbc7faf
@ -23,7 +23,15 @@ module VagrantPlugins
|
||||
mount_tag = Digest::MD5.new.update(opts[:hostpath]).to_s[0, 31]
|
||||
|
||||
mount_opts = '-o trans=virtio'
|
||||
mount_opts += ",access=#{opts[:owner]}" if opts[:owner]
|
||||
mount_opts += ",access=#{opts[:access]}" if opts[:access]
|
||||
if opts[:owner]
|
||||
if opts[:access]
|
||||
machine.ui.warn('deprecated `:owner` option ignored as replacement `:access` option already set, please update your Vagrantfile and remove the `:owner` option to prevent this warning.')
|
||||
else
|
||||
machine.ui.warn('`:owner` option for 9p mount options deprecated in favour of `:access`, please update your Vagrantfile and replace `:owner` with `:access`')
|
||||
mount_opts += ",access=#{opts[:owner]}"
|
||||
end
|
||||
end
|
||||
mount_opts += ",version=#{opts[:version]}" if opts[:version]
|
||||
mount_opts += ",#{opts[:mount_opts]}" if opts[:mount_opts]
|
||||
|
||||
|
76
spec/unit/cap/mount_9p_spec.rb
Normal file
76
spec/unit/cap/mount_9p_spec.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'support/sharedcontext'
|
||||
|
||||
require 'vagrant-libvirt'
|
||||
|
||||
describe 'VagrantPlugins::ProviderLibvirt::Cap::Mount9P' do
|
||||
include_context 'unit'
|
||||
|
||||
subject do
|
||||
VagrantPlugins::ProviderLibvirt::Plugin
|
||||
.components
|
||||
.guest_capabilities[:linux]
|
||||
.get(:mount_9p_shared_folder)
|
||||
end
|
||||
|
||||
let(:options) { {} }
|
||||
describe '#mount_9p_shared_folder' do
|
||||
let(:synced_folders) { {
|
||||
"/vagrant" => {
|
||||
:hostpath => '/home/test/default',
|
||||
:disabled=>false,
|
||||
:guestpath=>'~/vagrant',
|
||||
:type => :"9p",
|
||||
}.merge(options),
|
||||
} }
|
||||
|
||||
before do
|
||||
allow(guest).to receive(:capability).and_return('/home/vagrant/vagant')
|
||||
allow(communicator).to receive(:sudo).with('mkdir -p /home/vagrant/vagant')
|
||||
end
|
||||
|
||||
it 'should succeed' do
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9p')
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9pnet_virtio')
|
||||
expect(communicator).to receive(:sudo).with(/mount -t 9p.*/, instance_of(Hash))
|
||||
expect(ui).to_not receive(:warn)
|
||||
|
||||
subject.mount_9p_shared_folder(machine, synced_folders)
|
||||
end
|
||||
|
||||
context 'with owner option set' do
|
||||
let(:options) { {
|
||||
:owner=> 'user',
|
||||
} }
|
||||
|
||||
it 'should warn option is deprecated' do
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9p')
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9pnet_virtio')
|
||||
expect(communicator).to receive(:sudo).with(
|
||||
/mount -t 9p -o trans=virtio,access=user .*/,
|
||||
instance_of(Hash))
|
||||
expect(ui).to receive(:warn).with(/`:owner` option for 9p mount options deprecated/)
|
||||
|
||||
subject.mount_9p_shared_folder(machine, synced_folders)
|
||||
end
|
||||
|
||||
context 'with access option set' do
|
||||
let(:options) { {
|
||||
:owner=> 'user',
|
||||
:access=> 'user',
|
||||
} }
|
||||
|
||||
it 'should warn owner option is ignored' do
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9p')
|
||||
expect(communicator).to receive(:sudo).with('modprobe 9pnet_virtio')
|
||||
expect(communicator).to receive(:sudo).with(/mount -t 9p.*/, instance_of(Hash))
|
||||
expect(ui).to receive(:warn).with(/deprecated `:owner` option ignored/)
|
||||
|
||||
subject.mount_9p_shared_folder(machine, synced_folders)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user