From 32c77ef96a4ff69ff7ec2a6d77a4d21a96a520cd Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 7 Feb 2022 14:27:11 -0800 Subject: [PATCH] Remove need for environment when mapping machine --- plugins/commands/serve/mappers/machine.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/plugins/commands/serve/mappers/machine.rb b/plugins/commands/serve/mappers/machine.rb index b83fa495c..d76579ce9 100644 --- a/plugins/commands/serve/mappers/machine.rb +++ b/plugins/commands/serve/mappers/machine.rb @@ -58,12 +58,13 @@ module VagrantPlugins def initialize inputs = [].tap do |i| i << Input.new(type: Client::Target) - i << Input.new(type: Vagrant::Environment) + i << Input.new(type: Mappers) end super(inputs: inputs, output: Vagrant::Machine, func: method(:converter)) end - def converter(target, env) + def converter(target, mappers) + env = mappers.map(target.project, to: Vagrant::Environment) env.machine( target.name.to_sym, target.provider_name.to_sym, @@ -90,10 +91,10 @@ module VagrantPlugins end end - class MachineToProto < Mapper + class MachineClientToProto < Mapper def initialize super( - inputs: [Input.new(type:Client::Target::Machine)], + inputs: [Input.new(type: Client::Target::Machine)], output: SDK::Args::Target::Machine, func: method(:converter), ) @@ -137,6 +138,20 @@ module VagrantPlugins ) end end + + class MachineToProto < Mapper + def initialize + super( + inputs: [Input.new(type: Vagrant::Machine)], + output: SDK::Args::Target::Machine, + func: method(:converter), + ) + end + + def converter(machine) + machine.client.to_proto + end + end end end end