Fixes #11358: Actually validate synced_folder type options

Prior to this commit, Vagrant wouldn't validate the `type` option for
any synced_folder configs defined. This commit updates that behavior to
look at the current list of installed synced_folder plugins, and ensure
if a type is defined, it's a valid plugin in that list.
This commit is contained in:
Brian Cain 2020-01-31 09:00:27 -08:00
parent f5d57e376f
commit 82b2630a80
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 14 additions and 3 deletions

View File

@ -755,9 +755,14 @@ module VagrantPlugins
errors << I18n.t("vagrant.config.vm.shared_folder_mount_options_array")
end
# One day remove this probably.
if options[:extra]
errors << "The 'extra' flag on synced folders is now 'mount_options'"
if options[:type]
plugins = Vagrant.plugin("2").manager.synced_folders
impl_class = plugins[options[:type]]
if !impl_class
errors << I18n.t("vagrant.config.vm.shared_folder_invalid_option_type",
type: options[:type],
options: plugins.keys.join(', '))
end
end
end

View File

@ -1943,6 +1943,12 @@ en:
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_invalid_option_type: |-
The type '%{type}' is not a valid synced folder type. If 'type' is not
specified, Vagrant will automatically choose the best synced folder
option for your guest. Otherwise, please pick from the following valid options:
%{options}
shared_folder_nfs_owner_group: |-
Shared folders that have NFS enabled do not support owner/group
attributes. Host path: %{path}