Add machine to_proto mapper and update from target

This commit is contained in:
Chris Roberts 2021-11-17 14:56:49 -08:00 committed by Paul Hinze
parent b7c04b4ecc
commit ce3f18ada1
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -53,13 +53,13 @@ module VagrantPlugins
class MachineFromTarget < Mapper
def initialize
inputs = [].tap do |i|
i << Input.new(type: Vagrant::Environment)
i << Input.new(type: Client::Target)
i << Input.new(type: Vagrant::Environment)
end
super(inputs: inputs, output: Vagrant::Machine, func: method(:converter))
end
def converter(env, target)
def converter(target, env)
env.machine(
target.name.to_sym,
target.provider_name.to_sym,
@ -71,19 +71,34 @@ module VagrantPlugins
class MachineFromMachineClient < Mapper
def initialize
inputs = [].tap do |i|
i << Input.new(type: Vagrant::Environment)
i << Input.new(type: Client::Target::Machine)
i << Input.new(type: Mappers)
end
super(inputs: inputs, output: Vagrant::Machine, func: method(:converter))
end
def converter(env, machine)
def converter(machine, mappers)
env = mappers.map(machine.project, to: Vagrant::Environment)
env.machine(
machine.name.to_sym,
machine.provider_name.to_sym,
)
end
end
class MachineToProto < Mapper
def initialize
super(
inputs: [Input.new(type:Client::Target::Machine)],
output: SDK::Args::Target::Machine,
func: method(:converter),
)
end
def converter(m)
m.to_proto
end
end
end
end
end