Add some missing mappers for converting to proto
This commit is contained in:
parent
6dd5a3ae9b
commit
ab8dee7a72
@ -20,7 +20,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
# Build a guest client from a FuncSpec value
|
||||
class HostFromSpec < Mapper
|
||||
class HostClientFromSpec < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
@ -38,7 +38,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
# Build a guest client from a proto instance
|
||||
class HostFromProto < Mapper
|
||||
class HostClientFromProto < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::Args::Host)
|
||||
@ -51,6 +51,59 @@ module VagrantPlugins
|
||||
Client::Host.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
|
||||
class HostFromClient < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: Client::Host),
|
||||
],
|
||||
output: Vagrant::Host,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(client)
|
||||
Vagrant::Host.new(
|
||||
client, nil,
|
||||
Vagrant.plugin("2").
|
||||
local_manager.
|
||||
host_capabilities
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class HostProtoFromHost < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: Vagrant::Host)
|
||||
],
|
||||
output: SDK::Args::Host,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(host)
|
||||
host.client.to_proto
|
||||
end
|
||||
end
|
||||
|
||||
class HostProtoFromClient < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: Client::Host),
|
||||
],
|
||||
output: SDK::Args::Host,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(client)
|
||||
client.to_proto
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -52,6 +52,38 @@ module VagrantPlugins
|
||||
Client::TargetIndex.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
|
||||
class TargetIndexToProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: Client::TargetIndex),
|
||||
],
|
||||
output: SDK::Args::TargetIndex,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(index)
|
||||
index.to_proto
|
||||
end
|
||||
end
|
||||
|
||||
class MachineIndexToProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: Vagrant::MachineIndex),
|
||||
],
|
||||
output: SDK::Args::TargetIndex,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(index)
|
||||
index.client.to_proto
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user