Add mount_name synced folder capability to get name of mount
This commit is contained in:
parent
3afd646a27
commit
00e4810197
@ -18,10 +18,9 @@ module VagrantPlugins
|
||||
def self.mount_smb_shared_folder(machine, name, guestpath, options)
|
||||
expanded_guest_path = machine.guest.capability(
|
||||
:shell_expand_guest_path, guestpath)
|
||||
|
||||
mount_device = "//#{options[:smb_host]}/#{name}"
|
||||
|
||||
options[:smb_id] ||= name
|
||||
|
||||
mount_device = options[:plugin].capability(:mount_name, options)
|
||||
mount_options, _, _ = options[:plugin].capability(
|
||||
:mount_options, name, expanded_guest_path, options)
|
||||
mount_type = options[:plugin].capability(:mount_type)
|
||||
@ -30,7 +29,6 @@ module VagrantPlugins
|
||||
smb_password = options[:smb_password]
|
||||
# Ensure password is scrubbed
|
||||
Vagrant::Util::CredentialScrubber.sensitive(smb_password)
|
||||
|
||||
|
||||
if mount_options.include?("mfsymlinks")
|
||||
display_mfsymlinks_warning(machine.env)
|
||||
|
||||
@ -31,15 +31,11 @@ module VagrantPlugins
|
||||
data[:owner] ||= ssh_info[:username]
|
||||
data[:group] ||= ssh_info[:username]
|
||||
mount_type = data[:plugin].capability(:mount_type)
|
||||
|
||||
if type == :smb
|
||||
data[:smb_host] ||= machine.guest.capability(
|
||||
:choose_addressable_ip_addr, candidate_ips)
|
||||
name = "//#{data[:smb_host]}/#{data[:smb_id]}"
|
||||
end
|
||||
|
||||
mount_options, _, _ = data[:plugin].capability(
|
||||
:mount_options, name, guest_path, data)
|
||||
if data[:plugin].capability?(:mount_name)
|
||||
name = data[:plugin].capability(:mount_name, data)
|
||||
end
|
||||
else
|
||||
next
|
||||
end
|
||||
|
||||
@ -44,6 +44,12 @@ module VagrantPlugins
|
||||
def self.mount_type(machine)
|
||||
return MOUNT_TYPE
|
||||
end
|
||||
|
||||
def self.mount_name(machine, data)
|
||||
data[:smb_host] ||= machine.guest.capability(
|
||||
:choose_addressable_ip_addr, candidate_ips)
|
||||
"//#{data[:smb_host]}/#{data[:smb_id]}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,6 +33,11 @@ module VagrantPlugins
|
||||
Cap::MountOptions
|
||||
end
|
||||
|
||||
synced_folder_capability("smb", "mount_name") do
|
||||
require_relative "cap/mount_options"
|
||||
Cap::MountOptions
|
||||
end
|
||||
|
||||
synced_folder_capability("smb", "mount_type") do
|
||||
require_relative "cap/mount_options"
|
||||
Cap::MountOptions
|
||||
|
||||
@ -43,6 +43,7 @@ describe "VagrantPlugins::GuestLinux::Cap::MountSMBSharedFolder" do
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_options, mount_name, mount_guest_path, folder_options).
|
||||
and_return(["uid=#{mount_uid},gid=#{mount_gid},sec=ntlmssp,credentials=/etc/smb_creds_id", mount_uid, mount_gid])
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("cifs")
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_name, any_args).and_return("//localhost/#{mount_name}")
|
||||
end
|
||||
|
||||
after do
|
||||
|
||||
@ -34,6 +34,7 @@ describe "VagrantPlugins::GuestLinux::Cap::PersistMountSharedFolder" do
|
||||
before do
|
||||
allow(machine).to receive(:communicate).and_return(comm)
|
||||
allow(machine).to receive(:ssh_info).and_return(ssh_info)
|
||||
allow(folder_plugin).to receive(:capability?).with(:mount_name).and_return(false)
|
||||
allow(folder_plugin).to receive(:capability?).with(:mount_type).and_return(true)
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_options, any_args).
|
||||
and_return(["uid=#{options_uid},gid=#{options_gid}", options_uid, options_gid])
|
||||
@ -116,17 +117,21 @@ describe "VagrantPlugins::GuestLinux::Cap::PersistMountSharedFolder" do
|
||||
:smb => fstab_folders
|
||||
} }
|
||||
|
||||
before do
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("cifs")
|
||||
end
|
||||
|
||||
it "inserts folders into /etc/fstab" do
|
||||
expected_entry_vagrant = "//192.168.42.42/vtg-id2 /vagrant cifs #{expected_mount_options} 0 0"
|
||||
expected_entry_test = "//192.168.42.42/vtg-id1 /test1 cifs #{expected_mount_options} 0 0"
|
||||
expect(cap).to receive(:remove_vagrant_managed_fstab)
|
||||
expect(comm).to receive(:sudo).with(/#{expected_entry_test}\n#{expected_entry_vagrant}/)
|
||||
|
||||
cap.persist_mount_shared_folder(machine, folders)
|
||||
context "folder with mount_name cap" do
|
||||
before do
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("cifs")
|
||||
allow(folder_plugin).to receive(:capability?).with(:mount_name).and_return(true)
|
||||
allow(folder_plugin).to receive(:capability).with(:mount_name, any_args).and_return("//192.168.42.42/dummyname")
|
||||
end
|
||||
|
||||
it "inserts folders into /etc/fstab" do
|
||||
expected_entry_vagrant = "//192.168.42.42/dummyname /vagrant cifs #{expected_mount_options} 0 0"
|
||||
expected_entry_test = "//192.168.42.42/dummyname /test1 cifs #{expected_mount_options} 0 0"
|
||||
expect(cap).to receive(:remove_vagrant_managed_fstab)
|
||||
expect(comm).to receive(:sudo).with(/#{expected_entry_test}\n#{expected_entry_vagrant}/)
|
||||
|
||||
cap.persist_mount_shared_folder(machine, folders)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user