Add mappers for box proto to client

This commit is contained in:
sophia 2021-11-10 15:57:51 -06:00 committed by Paul Hinze
parent d0f7d89104
commit 99694b210b
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 21 additions and 0 deletions

View File

@ -160,6 +160,7 @@ end
# NOTE: Always directly load mappers so they are automatically registered and
# available. Using autoloading behavior will result in them being unaavailable
# until explicitly requested by name
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/direct.rb").to_s

View File

@ -0,0 +1,20 @@
module VagrantPlugins
module CommandServe
class Mappers
# Build a box client from a proto instance
class BoxFromProto < Mapper
def initialize
inputs = [].tap do |i|
i << Input.new(type: SDK::Args::Box)
i << Input.new(type: Broker)
end
super(inputs: inputs, output: Client::Box, func: method(:converter))
end
def converter(proto, broker)
Client::Box.load(proto, broker: broker)
end
end
end
end
end