Add mapper for communincator path proto

This commit is contained in:
sophia 2021-10-29 15:24:32 -05:00 committed by Paul Hinze
parent 1f2084cd17
commit 8a2375faf2
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 29 additions and 12 deletions

View File

@ -76,12 +76,12 @@ module VagrantPlugins
value: Google::Protobuf::Any.pack(machine.to_proto)
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
value: Google::Protobuf::Any.pack(SDK::Args::Path.new(path: from)),
type: "hashicorp.vagrant.sdk.Communicator.Path",
value: Google::Protobuf::Any.pack(SDK::Communicator::Path.new(path: from)),
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
value: Google::Protobuf::Any.pack(SDK::Args::Path.new(path: to)),
type: "hashicorp.vagrant.sdk.Communicator.Path",
value: Google::Protobuf::Any.pack(SDK::Communicator::Path.new(path: to)),
),
]
)
@ -102,12 +102,12 @@ module VagrantPlugins
value: Google::Protobuf::Any.pack(machine.to_proto)
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
value: Google::Protobuf::Any.pack(SDK::Args::Path.new(path: from)),
type: "hashicorp.vagrant.sdk.Communicator.Path",
value: Google::Protobuf::Any.pack(SDK::Communicator::Path.new(path: from)),
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
value: Google::Protobuf::Any.pack(SDK::Args::Path.new(path: to)),
type: "hashicorp.vagrant.sdk.Communicator.Path",
value: Google::Protobuf::Any.pack(SDK::Communicator::Path.new(path: to)),
),
]
)

View File

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

View File

@ -110,11 +110,11 @@ module VagrantPlugins
name: "",
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
type: "hashicorp.vagrant.sdk.Communicator.Path",
name: "",
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
type: "hashicorp.vagrant.sdk.Communicator.Path",
name: "",
)
],
@ -161,11 +161,11 @@ module VagrantPlugins
name: "",
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
type: "hashicorp.vagrant.sdk.Communicator.Path",
name: "",
),
SDK::FuncSpec::Value.new(
type: "hashicorp.vagrant.sdk.Args.Path",
type: "hashicorp.vagrant.sdk.Communicator.Path",
name: "",
)
],