core: verify explicit sf types are usable
This commit is contained in:
parent
2c8b6ace7f
commit
ab70dc271b
|
@ -124,10 +124,19 @@ module Vagrant
|
||||||
impl = ""
|
impl = ""
|
||||||
impl = data[:type].to_sym if data[:type]
|
impl = data[:type].to_sym if data[:type]
|
||||||
|
|
||||||
if impl != "" && !plugins[impl]
|
if impl != ""
|
||||||
# This should never happen because configuration validation
|
impl_class = plugins[impl]
|
||||||
# should catch this case. But we put this here as an assert
|
if !impl_class
|
||||||
raise "Internal error. Report this as a bug. Invalid: #{data[:type]}"
|
# 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
|
end
|
||||||
|
|
||||||
# Keep track of this shared folder by the implementation.
|
# Keep track of this shared folder by the implementation.
|
||||||
|
|
|
@ -512,6 +512,10 @@ module Vagrant
|
||||||
error_key(:ssh_unavailable_windows)
|
error_key(:ssh_unavailable_windows)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class SyncedFolderUnusable < VagrantError
|
||||||
|
error_key(:synced_folder_unusable)
|
||||||
|
end
|
||||||
|
|
||||||
class UIExpectsTTY < VagrantError
|
class UIExpectsTTY < VagrantError
|
||||||
error_key(:ui_expects_tty)
|
error_key(:ui_expects_tty)
|
||||||
end
|
end
|
||||||
|
|
|
@ -580,6 +580,10 @@ en:
|
||||||
Port: %{port}
|
Port: %{port}
|
||||||
Username: %{username}
|
Username: %{username}
|
||||||
Private key: %{key_path}
|
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"
|
test_key: "test value"
|
||||||
ui_expects_tty: |-
|
ui_expects_tty: |-
|
||||||
Vagrant is attempting to interface with the UI in a way that requires
|
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"] }
|
result[:nfs].should == { "nfs" => folders["nfs"] }
|
||||||
end
|
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
|
it "should ignore disabled folders" do
|
||||||
folders["root"] = {}
|
folders["root"] = {}
|
||||||
folders["foo"] = { disabled: true }
|
folders["foo"] = { disabled: true }
|
||||||
|
|
Loading…
Reference in New Issue