Shared folders with the same guest path overwrite each other
This commit is contained in:
parent
ba07d303e5
commit
f48587bcd1
|
@ -53,6 +53,8 @@ IMPROVEMENTS:
|
||||||
- Show a message on `vagrant up` if the machine is already running. [GH-1558]
|
- Show a message on `vagrant up` if the machine is already running. [GH-1558]
|
||||||
- "Running provisioner" output now shoes the provisioner shortcut name,
|
- "Running provisioner" output now shoes the provisioner shortcut name,
|
||||||
rather than the less-than-helpful class name.
|
rather than the less-than-helpful class name.
|
||||||
|
- Shared folders with the same guest path will overwrite each other. No
|
||||||
|
more shared folder IDs.
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,12 @@ module VagrantPlugins
|
||||||
attr_accessor :guest
|
attr_accessor :guest
|
||||||
attr_accessor :hostname
|
attr_accessor :hostname
|
||||||
attr_accessor :usable_port_range
|
attr_accessor :usable_port_range
|
||||||
attr_reader :synced_folders
|
|
||||||
attr_reader :provisioners
|
attr_reader :provisioners
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@graceful_halt_retry_count = UNSET_VALUE
|
@graceful_halt_retry_count = UNSET_VALUE
|
||||||
@graceful_halt_retry_interval = UNSET_VALUE
|
@graceful_halt_retry_interval = UNSET_VALUE
|
||||||
@hostname = UNSET_VALUE
|
@hostname = UNSET_VALUE
|
||||||
@synced_folders = {}
|
|
||||||
@provisioners = []
|
@provisioners = []
|
||||||
|
|
||||||
# Internal state
|
# Internal state
|
||||||
|
@ -39,6 +37,7 @@ module VagrantPlugins
|
||||||
@__finalized = false
|
@__finalized = false
|
||||||
@__networks = {}
|
@__networks = {}
|
||||||
@__providers = {}
|
@__providers = {}
|
||||||
|
@__synced_folders = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Custom merge method since some keys here are merged differently.
|
# Custom merge method since some keys here are merged differently.
|
||||||
|
@ -47,7 +46,6 @@ module VagrantPlugins
|
||||||
other_networks = other.instance_variable_get(:@__networks)
|
other_networks = other.instance_variable_get(:@__networks)
|
||||||
|
|
||||||
result.instance_variable_set(:@__networks, @__networks.merge(other_networks))
|
result.instance_variable_set(:@__networks, @__networks.merge(other_networks))
|
||||||
result.instance_variable_set(:@synced_folders, @synced_folders.merge(other.synced_folders))
|
|
||||||
result.instance_variable_set(:@provisioners, @provisioners + other.provisioners)
|
result.instance_variable_set(:@provisioners, @provisioners + other.provisioners)
|
||||||
|
|
||||||
# Merge defined VMs by first merging the defined VM keys,
|
# Merge defined VMs by first merging the defined VM keys,
|
||||||
|
@ -55,7 +53,6 @@ module VagrantPlugins
|
||||||
other_defined_vm_keys = other.instance_variable_get(:@__defined_vm_keys)
|
other_defined_vm_keys = other.instance_variable_get(:@__defined_vm_keys)
|
||||||
other_defined_vm_keys -= @__defined_vm_keys
|
other_defined_vm_keys -= @__defined_vm_keys
|
||||||
new_defined_vm_keys = @__defined_vm_keys + other_defined_vm_keys
|
new_defined_vm_keys = @__defined_vm_keys + other_defined_vm_keys
|
||||||
result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys)
|
|
||||||
|
|
||||||
# Merge the actual defined VMs.
|
# Merge the actual defined VMs.
|
||||||
other_defined_vms = other.instance_variable_get(:@__defined_vms)
|
other_defined_vms = other.instance_variable_get(:@__defined_vms)
|
||||||
|
@ -74,8 +71,6 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
result.instance_variable_set(:@__defined_vms, new_defined_vms)
|
|
||||||
|
|
||||||
# Merge the providers by prepending any configuration blocks we
|
# Merge the providers by prepending any configuration blocks we
|
||||||
# have for providers onto the new configuration.
|
# have for providers onto the new configuration.
|
||||||
other_providers = other.instance_variable_get(:@__providers)
|
other_providers = other.instance_variable_get(:@__providers)
|
||||||
|
@ -85,7 +80,18 @@ module VagrantPlugins
|
||||||
new_providers[key] += blocks
|
new_providers[key] += blocks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Merge synced folders.
|
||||||
|
other_folders = other.instance_variable_get(:@__synced_folders)
|
||||||
|
new_folders = @__synced_folders.dup
|
||||||
|
other_folders.each do |id, options|
|
||||||
|
new_folders[id] ||= {}
|
||||||
|
new_folders[id].merge!(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys)
|
||||||
|
result.instance_variable_set(:@__defined_vms, new_defined_vms)
|
||||||
result.instance_variable_set(:@__providers, new_providers)
|
result.instance_variable_set(:@__providers, new_providers)
|
||||||
|
result.instance_variable_set(:@__synced_folders, new_folders)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,11 +109,10 @@ module VagrantPlugins
|
||||||
# @param [Hash] options Additional options.
|
# @param [Hash] options Additional options.
|
||||||
def synced_folder(hostpath, guestpath, options=nil)
|
def synced_folder(hostpath, guestpath, options=nil)
|
||||||
options ||= {}
|
options ||= {}
|
||||||
options[:id] ||= guestpath.to_s.gsub(/\/$/, '')
|
options[:guestpath] = guestpath.to_s.gsub(/\/$/, '')
|
||||||
options[:guestpath] = guestpath
|
|
||||||
options[:hostpath] = hostpath
|
options[:hostpath] = hostpath
|
||||||
|
|
||||||
@synced_folders[options[:id]] = options
|
@__synced_folders[options[:guestpath]] = 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
|
||||||
|
@ -267,6 +272,11 @@ module VagrantPlugins
|
||||||
@__networks.values
|
@__networks.values
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This returns the list of synced folders
|
||||||
|
def synced_folders
|
||||||
|
@__synced_folders
|
||||||
|
end
|
||||||
|
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
errors = _detected_errors
|
errors = _detected_errors
|
||||||
errors << I18n.t("vagrant.config.vm.box_missing") if !box
|
errors << I18n.t("vagrant.config.vm.box_missing") if !box
|
||||||
|
@ -277,7 +287,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
has_nfs = false
|
has_nfs = false
|
||||||
used_guest_paths = Set.new
|
used_guest_paths = Set.new
|
||||||
@synced_folders.each do |id, options|
|
@__synced_folders.each do |id, options|
|
||||||
# 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]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue