Use named paths proto message for uploading/downloading
This commit is contained in:
parent
a52b8b7fd3
commit
49ad851606
@ -42,6 +42,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
add_message "hashicorp.vagrant.sdk.Args.MetadataSet" do
|
||||
map :metadata, :string, :string, 1
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Args.NamedPath" do
|
||||
optional :name, :string, 1
|
||||
optional :path, :string, 2
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Args.NamedPaths" do
|
||||
repeated :paths, :message, 1, "hashicorp.vagrant.sdk.Args.NamedPath"
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Args.TerminalUI" do
|
||||
optional :stream_id, :uint32, 1
|
||||
optional :network, :string, 2
|
||||
@ -448,12 +455,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
add_message "hashicorp.vagrant.sdk.Communicator.Command" do
|
||||
optional :command, :string, 1
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Communicator.Path" do
|
||||
optional :path, :string, 1
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Communicator.RemotePath" do
|
||||
optional :path, :string, 1
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Platform" do
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.Platform.DetectResp" do
|
||||
@ -737,6 +738,8 @@ module Hashicorp
|
||||
Args::DataDir::Target = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.DataDir.Target").msgclass
|
||||
Args::DataDir::Component = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.DataDir.Component").msgclass
|
||||
Args::MetadataSet = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.MetadataSet").msgclass
|
||||
Args::NamedPath = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.NamedPath").msgclass
|
||||
Args::NamedPaths = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.NamedPaths").msgclass
|
||||
Args::TerminalUI = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.TerminalUI").msgclass
|
||||
Args::Logger = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.Logger").msgclass
|
||||
Args::JobInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.JobInfo").msgclass
|
||||
@ -828,8 +831,6 @@ module Hashicorp
|
||||
Communicator::ExecuteResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Communicator.ExecuteResp").msgclass
|
||||
Communicator::TestResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Communicator.TestResp").msgclass
|
||||
Communicator::Command = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Communicator.Command").msgclass
|
||||
Communicator::Path = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Communicator.Path").msgclass
|
||||
Communicator::RemotePath = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Communicator.RemotePath").msgclass
|
||||
Platform = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Platform").msgclass
|
||||
Platform::DetectResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Platform.DetectResp").msgclass
|
||||
Platform::ParentResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Platform.ParentResp").msgclass
|
||||
|
||||
@ -76,12 +76,14 @@ module VagrantPlugins
|
||||
value: Google::Protobuf::Any.pack(machine.to_proto)
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
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.Communicator.RemotePath",
|
||||
value: Google::Protobuf::Any.pack(SDK::Communicator::RemotePath.new(path: to)),
|
||||
type: "hashicorp.vagrant.sdk.Args.NamedPaths",
|
||||
value: Google::Protobuf::Any.pack(
|
||||
SDK::Args::NamedPaths.new(
|
||||
paths: [
|
||||
SDK::Args::NamedPath.new(path: from, name: "from"),
|
||||
SDK::Args::NamedPath.new(path: to, name: "to"),
|
||||
])
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
@ -102,12 +104,14 @@ module VagrantPlugins
|
||||
value: Google::Protobuf::Any.pack(machine.to_proto)
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
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.Communicator.RemotePath",
|
||||
value: Google::Protobuf::Any.pack(SDK::Communicator::RemotePath.new(path: to)),
|
||||
type: "hashicorp.vagrant.sdk.Args.NamedPaths",
|
||||
value: Google::Protobuf::Any.pack(
|
||||
SDK::Args::NamedPaths.new(
|
||||
paths: [
|
||||
SDK::Args::NamedPath.new(path: from, name: "from"),
|
||||
SDK::Args::NamedPath.new(path: to, name: "to"),
|
||||
])
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@ -23,31 +23,15 @@ module VagrantPlugins
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Communicator.Path" &&
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.NamedPaths" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
end
|
||||
super(inputs: inputs, output: SDK::Communicator::Path, func: method(:converter))
|
||||
super(inputs: inputs, output: SDK::Args::NamedPaths, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto)
|
||||
SDK::Communicator::Path.decode(proto.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class CommunicatorRemotePathFromSpec < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Communicator.RemotePath" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
end
|
||||
super(inputs: inputs, output: SDK::Communicator::RemotePath, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto)
|
||||
SDK::Communicator::RemotePath.decode(proto.value.value)
|
||||
SDK::Args::NamedPaths.decode(proto.value.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -110,13 +110,8 @@ module VagrantPlugins
|
||||
name: "",
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Communicator.Path",
|
||||
name: "",
|
||||
type: "hashicorp.vagrant.sdk.Args.NamedPaths",
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Communicator.RemotePath",
|
||||
name: "",
|
||||
)
|
||||
],
|
||||
result: []
|
||||
)
|
||||
@ -128,10 +123,11 @@ module VagrantPlugins
|
||||
plugin_name = info.plugin_name
|
||||
logger.debug("Got plugin #{plugin_name}")
|
||||
|
||||
target, from, to = mapper.funcspec_map(req)
|
||||
target, paths = mapper.funcspec_map(req)
|
||||
logger.debug("Got target #{target}")
|
||||
logger.debug("Got from #{from}")
|
||||
logger.debug("Got to #{to}")
|
||||
logger.debug("Got paths #{paths}")
|
||||
from = paths.paths.select{ |p| p.name == "from" }.first
|
||||
to = paths.paths.select{ |p| p.name == "to" }.first
|
||||
|
||||
logger.info("mapping received arguments to guest machine")
|
||||
machine = mapper.map(target, to: Vagrant::Machine)
|
||||
@ -143,7 +139,7 @@ module VagrantPlugins
|
||||
communicator = plugin.new(machine)
|
||||
logger.debug("communicator: #{communicator}")
|
||||
|
||||
communicator.download(from, to)
|
||||
communicator.download(from.path, to.path)
|
||||
|
||||
Empty.new
|
||||
end
|
||||
@ -158,11 +154,8 @@ module VagrantPlugins
|
||||
name: "",
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Communicator.Path",
|
||||
type: "hashicorp.vagrant.sdk.Args.NamedPaths",
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Communicator.RemotePath",
|
||||
)
|
||||
],
|
||||
result: []
|
||||
)
|
||||
@ -174,10 +167,11 @@ module VagrantPlugins
|
||||
plugin_name = info.plugin_name
|
||||
logger.debug("Got plugin #{plugin_name}")
|
||||
|
||||
target, from, to = mapper.funcspec_map(req)
|
||||
target, paths = mapper.funcspec_map(req)
|
||||
logger.debug("Got target #{target}")
|
||||
logger.debug("Got from #{from}")
|
||||
logger.debug("Got to #{to}")
|
||||
logger.debug("Got paths #{paths}")
|
||||
from = paths.paths.select{ |p| p.name == "from" }.first
|
||||
to = paths.paths.select{ |p| p.name == "to" }.first
|
||||
|
||||
project = target.project
|
||||
env = Vagrant::Environment.new({client: project})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user