diff --git a/plugins/commands/serve/mappers/known_types.rb b/plugins/commands/serve/mappers/known_types.rb index b5b8608d2..21dcf245f 100644 --- a/plugins/commands/serve/mappers/known_types.rb +++ b/plugins/commands/serve/mappers/known_types.rb @@ -28,17 +28,56 @@ module VagrantPlugins ") end - class SymbolToString < Mapper + class ArrayToProto < Mapper def initialize super( - inputs: [Input.new(type: Symbol)], + inputs: [ + Input.new(type: Array), + Input.new(type: Mappers), + ], + output: SDK::Args::Array, + func: method(:converter), + ) + end + + def converter(array, mapper) + r = array.map do |v| + mapper.map(v, to: Google::Protobuf::Any) + end + SDK::Args::Array.new(list: r) + end + end + + class ArrayFromProto < Mapper + def initialize + super( + inputs: [ + Input.new(type: SDK::Args::Array), + Input.new(type: Mappers), + ], + output: Array, + func: method(:converter), + ) + end + + def converter(proto, mapper) + proto.list.map do |v| + mapper.map(v) + end + end + end + + class ClassToString < Mapper + def initialize + super( + inputs: [Input.new(type: Class)], output: String, func: method(:converter), ) end - def converter(sym) - sym.to_s + def converter(cls) + cls.to_s end end @@ -99,49 +138,23 @@ module VagrantPlugins Hash.new.tap do |result| proto.fields.each do |k, v| r = mapper.map(v) - # result[k.to_s] = r result[k.to_sym] = r end end end end - class ArrayToProto < Mapper + class SymbolToString < Mapper def initialize super( - inputs: [ - Input.new(type: Array), - Input.new(type: Mappers), - ], - output: SDK::Args::Array, + inputs: [Input.new(type: Symbol)], + output: String, func: method(:converter), ) end - def converter(array, mapper) - r = array.map do |v| - mapper.map(v, to: Google::Protobuf::Any) - end - SDK::Args::Array.new(list: r) - end - end - - class ArrayFromProto < Mapper - def initialize - super( - inputs: [ - Input.new(type: SDK::Args::Array), - Input.new(type: Mappers), - ], - output: Array, - func: method(:converter), - ) - end - - def converter(proto, mapper) - proto.list.map do |v| - mapper.map(v) - end + def converter(sym) + sym.to_s end end end diff --git a/plugins/providers/virtualbox/synced_folder.rb b/plugins/providers/virtualbox/synced_folder.rb index d78c5f7ba..c983f18ff 100644 --- a/plugins/providers/virtualbox/synced_folder.rb +++ b/plugins/providers/virtualbox/synced_folder.rb @@ -4,7 +4,6 @@ require "vagrant/util/platform" module VagrantPlugins module ProviderVirtualBox class SyncedFolder < Vagrant.plugin("2", :synced_folder) - def usable?(machine, raise_errors=false) # These synced folders only work if the provider if VirtualBox return false if machine.provider_name != :virtualbox