Merge pull request #7980 from chrisroberts/synced-folder/auto-mount
Named synced folders
This commit is contained in:
commit
8d2d324b13
|
@ -207,7 +207,19 @@ module VagrantPlugins
|
||||||
hostpath = hostpath.to_s.gsub("\\", "/")
|
hostpath = hostpath.to_s.gsub("\\", "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if guestpath.is_a?(Hash)
|
||||||
|
options = guestpath
|
||||||
|
guestpath = nil
|
||||||
|
end
|
||||||
|
|
||||||
options ||= {}
|
options ||= {}
|
||||||
|
|
||||||
|
if options.has_key?(:name)
|
||||||
|
synced_folder_name = options.delete(:name)
|
||||||
|
else
|
||||||
|
synced_folder_name = guestpath
|
||||||
|
end
|
||||||
|
|
||||||
options[:guestpath] = guestpath.to_s.gsub(/\/$/, '')
|
options[:guestpath] = guestpath.to_s.gsub(/\/$/, '')
|
||||||
options[:hostpath] = hostpath
|
options[:hostpath] = hostpath
|
||||||
options[:disabled] = false if !options.key?(:disabled)
|
options[:disabled] = false if !options.key?(:disabled)
|
||||||
|
@ -217,7 +229,7 @@ module VagrantPlugins
|
||||||
# Make sure the type is a symbol
|
# Make sure the type is a symbol
|
||||||
options[:type] = options[:type].to_sym if options[:type]
|
options[:type] = options[:type].to_sym if options[:type]
|
||||||
|
|
||||||
@__synced_folders[options[:guestpath]] = options
|
@__synced_folders[synced_folder_name] = options
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define a way to access the machine via a network. This exposes a
|
# Define a way to access the machine via a network. This exposes a
|
||||||
|
@ -626,7 +638,7 @@ module VagrantPlugins
|
||||||
# If the shared folder is disabled then don't worry about validating it
|
# If the shared folder is disabled then don't worry about validating it
|
||||||
next if options[:disabled]
|
next if options[:disabled]
|
||||||
|
|
||||||
guestpath = Pathname.new(options[:guestpath])
|
guestpath = Pathname.new(options[:guestpath]) if options[:guestpath]
|
||||||
hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path)
|
hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path)
|
||||||
|
|
||||||
if guestpath.to_s != ""
|
if guestpath.to_s != ""
|
||||||
|
|
|
@ -534,6 +534,21 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
assert_valid
|
assert_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows providing custom name via options" do
|
||||||
|
subject.synced_folder(".", "/vagrant", name: "my-vagrant-folder")
|
||||||
|
sf = subject.synced_folders
|
||||||
|
expect(sf).to have_key("my-vagrant-folder")
|
||||||
|
expect(sf["my-vagrant-folder"][:guestpath]).to eq("/vagrant")
|
||||||
|
expect(sf["my-vagrant-folder"][:hostpath]).to eq(".")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows providing custom name without guest path" do
|
||||||
|
subject.synced_folder(".", name: "my-vagrant-folder")
|
||||||
|
sf = subject.synced_folders
|
||||||
|
expect(sf).to have_key("my-vagrant-folder")
|
||||||
|
expect(sf["my-vagrant-folder"][:hostpath]).to eq(".")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#usable_port_range" do
|
describe "#usable_port_range" do
|
||||||
|
|
Loading…
Reference in New Issue