Skip to content

Commit

Permalink
Fixes hashicorp#11358: Actually validate synced_folder type options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
briancain committed Jan 31, 2020
1 parent f5d57e3 commit 82b2630
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/kernel_v2/config/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,14 @@ def validate(machine, ignore_provider=nil)
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

Expand Down
6 changes: 6 additions & 0 deletions templates/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 82b2630

Please sign in to comment.