From 99694b210bbd07e3f5af9825b46d953c0437cfd0 Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 10 Nov 2021 15:57:51 -0600 Subject: [PATCH] Add mappers for box proto to client --- plugins/commands/serve/mappers.rb | 1 + plugins/commands/serve/mappers/box.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/commands/serve/mappers/box.rb diff --git a/plugins/commands/serve/mappers.rb b/plugins/commands/serve/mappers.rb index f07aad18f..6aaf51e77 100644 --- a/plugins/commands/serve/mappers.rb +++ b/plugins/commands/serve/mappers.rb @@ -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 diff --git a/plugins/commands/serve/mappers/box.rb b/plugins/commands/serve/mappers/box.rb new file mode 100644 index 000000000..6562724b7 --- /dev/null +++ b/plugins/commands/serve/mappers/box.rb @@ -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