Add mapper for communicator command

This commit is contained in:
sophia 2021-10-29 10:49:41 -05:00 committed by Paul Hinze
parent 4bc2a51748
commit ce6b2c8338
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 23 additions and 0 deletions

View File

@ -263,6 +263,7 @@ require Vagrant.source_root.join("plugins/commands/serve/mappers/basis.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/box.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/capabilities.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/command.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/communicator.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/direct.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/environment.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/guest.rb").to_s

View File

@ -0,0 +1,22 @@
module VagrantPlugins
module CommandServe
class Mappers
# Build a communicator command arguments from a FuncSpec value
class CommunicatorCommandArgumentsFromSpec < Mapper
def initialize
inputs = [].tap do |i|
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
arg.type == "hashicorp.vagrant.sdk.Communicator.Command" &&
!arg&.value&.value.nil?
}
end
super(inputs: inputs, output: SDK::Communicator::Command, func: method(:converter))
end
def converter(proto)
SDK::Communicator::Command.decode(proto.value.value)
end
end
end
end
end