Sha256: 24bd8f12267332286e02d8ef72f0e5de59a55dcea528fada54036d8c492798df
Contents?: true
Size: 1.99 KB
Versions: 4
Compression:
Stored size: 1.99 KB
Contents
module VagrantPlugins module CommandServe class Mappers class TargetProtoFromSpec < Mapper def initialize super( inputs: [ Input.new(type: SDK::FuncSpec::Value) { |arg| arg.type == "hashicorp.vagrant.sdk.Args.Target" && !arg&.value&.value.nil? } ], output: SDK::Args::Target, func: method(:converter) ) end def converter(fv) SDK::Args::Target.decode(fv.value.value) end end # Build a target client from a FuncSpec value class TargetFromSpec < Mapper def initialize inputs = [].tap do |i| i << Input.new(type: SDK::FuncSpec::Value) { |arg| arg.type == "hashicorp.vagrant.sdk.Args.Target" && !arg&.value&.value.nil? } i << Input.new(type: Broker) end super(inputs: inputs, output: Client::Target, func: method(:converter)) end def converter(proto, broker) Client::Target.load(proto.value.value, broker: broker) end end # Build a target client from a proto instance class TargetFromProto < Mapper def initialize inputs = [].tap do |i| i << Input.new(type: SDK::Args::Target) i << Input.new(type: Broker) end super(inputs: inputs, output: Client::Target, func: method(:converter)) end def converter(proto, broker) Client::Target.load(proto, broker: broker) end end class TargetToProto < Mapper def initialize super( inputs: [Input.new(type: Client::Target)], output: SDK::Args::Target, func: method(:converter), ) end def converter(t) return t.to_proto if t.class == Client::Target t.client.as_target(Empty.new) end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems