More comprehensive synced folder validation [GH-1499]

This commit is contained in:
Mitchell Hashimoto 2013-03-29 12:45:44 -07:00
parent b32c0d16ac
commit 40250843b3
3 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,7 @@ IMPROVEMENTS:
Vagrant errors much quieter when developing plugins.
- Vagrant will detect Bundler environments, make assumptions that you're
developing plugins, and will quiet its error output a bit.
- More comprehensive synced folder configuration validation.
BUG FIXES:

View File

@ -249,8 +249,25 @@ module VagrantPlugins
@hostname && @hostname !~ /^[-.a-z0-9]+$/i
has_nfs = false
used_guest_paths = Set.new
@synced_folders.each do |id, options|
hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path)
# If the shared folder is disabled then don't worry about validating it
next if options[:disabled]
guestpath = Pathname.new(options[:guestpath])
hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path)
if guestpath.relative?
errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_relative",
:path => options[:guestpath])
else
if used_guest_paths.include?(options[:guestpath])
errors << I18n.t("vagrant.config.vm.shared_folder_guestpath_duplicate",
:path => options[:guestpath])
end
used_guest_paths.add(options[:guestpath])
end
if !hostpath.directory? && !options[:create]
errors << I18n.t("vagrant.config.vm.shared_folder_hostpath_missing",

View File

@ -486,6 +486,11 @@ en:
Forwarded port definitions require a "host" and "guest" value
provisioner_not_found: |-
The '%{name}' provisioner could not be found.
shared_folder_guestpath_duplicate: |-
A shared folder guest path is used multiple times. Shared
folders must all map to a unique guest path: %{path}
shared_folder_guestpath_relative: |-
The shared folder guest path must be absolute: %{path}
shared_folder_hostpath_missing: |-
The host path of the shared folder is missing: %{path}
shared_folder_nfs_owner_group: |-