Add mappers for loading command client
This commit is contained in:
parent
23c99b5806
commit
3f7b7ee65a
@ -17,6 +17,38 @@ module VagrantPlugins
|
||||
SDK::Command::Arguments.decode(proto.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class CommandProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Command" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Command,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Command.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class CommandFromProto < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::Args::Command)
|
||||
i << Input.new(type: Broker)
|
||||
end
|
||||
super(inputs: inputs, output: Client::Command, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::Command.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user