core: verify explicit sf types are usable
This commit is contained in:
parent
2c8b6ace7f
commit
ab70dc271b
|
@ -124,10 +124,19 @@ module Vagrant
|
|||
impl = ""
|
||||
impl = data[:type].to_sym if data[:type]
|
||||
|
||||
if impl != "" && !plugins[impl]
|
||||
# This should never happen because configuration validation
|
||||
# should catch this case. But we put this here as an assert
|
||||
raise "Internal error. Report this as a bug. Invalid: #{data[:type]}"
|
||||
if impl != ""
|
||||
impl_class = plugins[impl]
|
||||
if !impl_class
|
||||
# This should never happen because configuration validation
|
||||
# should catch this case. But we put this here as an assert
|
||||
raise "Internal error. Report this as a bug. Invalid: #{data[:type]}"
|
||||
end
|
||||
|
||||
if !impl_class[0].new.usable?(machine)
|
||||
# Verify that explicitly defined shared folder types are
|
||||
# actually usable.
|
||||
raise Errors::SyncedFolderUnusable, type: data[:type].to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Keep track of this shared folder by the implementation.
|
||||
|
|
|
@ -512,6 +512,10 @@ module Vagrant
|
|||
error_key(:ssh_unavailable_windows)
|
||||
end
|
||||
|
||||
class SyncedFolderUnusable < VagrantError
|
||||
error_key(:synced_folder_unusable)
|
||||
end
|
||||
|
||||
class UIExpectsTTY < VagrantError
|
||||
error_key(:ui_expects_tty)
|
||||
end
|
||||
|
|
|
@ -580,6 +580,10 @@ en:
|
|||
Port: %{port}
|
||||
Username: %{username}
|
||||
Private key: %{key_path}
|
||||
synced_folder_unusable: |=
|
||||
The synced folder type '%{type}' is reporting as unusable for
|
||||
your current setup. Please verify you have all the proper
|
||||
prerequisites for using this shared folder type and try again.
|
||||
test_key: "test value"
|
||||
ui_expects_tty: |-
|
||||
Vagrant is attempting to interface with the UI in a way that requires
|
||||
|
|
|
@ -160,6 +160,14 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
|||
result[:nfs].should == { "nfs" => folders["nfs"] }
|
||||
end
|
||||
|
||||
it "should error if an explicit type is unusable" do
|
||||
plugins[:unusable] = [impl(false, "bad"), 15]
|
||||
folders["root"] = { type: "unusable" }
|
||||
|
||||
expect { subject.synced_folders(machine) }.
|
||||
to raise_error
|
||||
end
|
||||
|
||||
it "should ignore disabled folders" do
|
||||
folders["root"] = {}
|
||||
folders["foo"] = { disabled: true }
|
||||
|
|
Loading…
Reference in New Issue