Apply changes to download funciton
This commit is contained in:
parent
d57203f005
commit
bb084e42e4
@ -52,10 +52,16 @@ func (h *DummyCommunicator) DownloadFunc() interface{} {
|
||||
return h.Download
|
||||
}
|
||||
|
||||
func (h *DummyCommunicator) Download(
|
||||
machine plugincore.Machine,
|
||||
source, destination string,
|
||||
func (h *DummyCommunicator) Download(input struct {
|
||||
argmapper.Struct
|
||||
Machine plugincore.Machine `argmapper:",typeOnly"`
|
||||
Logger hclog.Logger `argmapper:",typeOnly"`
|
||||
Source string
|
||||
Destination string
|
||||
},
|
||||
) error {
|
||||
input.Logger.Debug("got Source ", input.Source)
|
||||
input.Logger.Debug("got Destination ", input.Destination)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -95,7 +101,7 @@ func (h *DummyCommunicator) PrivilegedExecuteFunc() interface{} {
|
||||
func (h *DummyCommunicator) PrivilegedExecute(
|
||||
machine plugincore.Machine,
|
||||
command []string,
|
||||
// options *pb.CommunicatorOptions,
|
||||
options *pb.CommunicatorOptions,
|
||||
) (status int32, err error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@ -68,6 +68,10 @@ module VagrantPlugins
|
||||
# @param [String] remote path
|
||||
# @param [String] local path
|
||||
def download(machine, from, to)
|
||||
from_val = Google::Protobuf::Value.new
|
||||
from_val.from_ruby(from)
|
||||
to_val = Google::Protobuf::Value.new
|
||||
to_val.from_ruby(to)
|
||||
req = SDK::FuncSpec::Args.new(
|
||||
args: [
|
||||
SDK::FuncSpec::Value.new(
|
||||
@ -76,14 +80,12 @@ module VagrantPlugins
|
||||
value: Google::Protobuf::Any.pack(machine.to_proto)
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
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"),
|
||||
])
|
||||
),
|
||||
name: "source",
|
||||
value: Google::Protobuf::Any.pack(from_val)
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
name: "destination",
|
||||
value: Google::Protobuf::Any.pack(to_val)
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@ -110,7 +110,10 @@ module VagrantPlugins
|
||||
name: "",
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Args.NamedPaths",
|
||||
name: "source"
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
name: "destination"
|
||||
),
|
||||
],
|
||||
result: []
|
||||
@ -123,23 +126,26 @@ module VagrantPlugins
|
||||
plugin_name = info.plugin_name
|
||||
logger.debug("Got plugin #{plugin_name}")
|
||||
|
||||
target, paths = mapper.funcspec_map(req)
|
||||
# Need to specifically now use funcspec map since the funcspec map
|
||||
# will inject results into the mappers. This causes duplicate values
|
||||
# to come up for arguments of the same type
|
||||
expected_types = [Client::Target::Machine, String, String]
|
||||
to, target, from = req.args.map do |r|
|
||||
logger.debug("mapping #{r}")
|
||||
mapper.map(r, expected_types.shift)
|
||||
end
|
||||
logger.debug("Got target #{target}")
|
||||
logger.debug("Got paths #{paths}")
|
||||
from = paths.paths.select{ |p| p.name == "from" }.first
|
||||
to = paths.paths.select{ |p| p.name == "to" }.first
|
||||
logger.debug("Got to #{to}")
|
||||
logger.debug("Got from #{from}")
|
||||
|
||||
logger.info("mapping received arguments to guest machine")
|
||||
machine = mapper.map(target, to: Vagrant::Machine)
|
||||
logger.debug("Got machine #{machine}")
|
||||
project = target.project
|
||||
env = Vagrant::Environment.new({client: project})
|
||||
machine = env.machine(target.name.to_sym, target.provider_name.to_sym)
|
||||
|
||||
plugin = Vagrant.plugin("2").manager.communicators[plugin_name.to_s.to_sym]
|
||||
logger.debug("Got plugin #{plugin}")
|
||||
|
||||
communicator = plugin.new(machine)
|
||||
logger.debug("communicator: #{communicator}")
|
||||
|
||||
communicator.download(from.path, to.path)
|
||||
communicator.download(from, to)
|
||||
|
||||
Empty.new
|
||||
end
|
||||
@ -188,11 +194,7 @@ module VagrantPlugins
|
||||
plugin = Vagrant.plugin("2").manager.communicators[plugin_name.to_s.to_sym]
|
||||
logger.debug("Got plugin #{plugin}")
|
||||
communicator = plugin.new(machine)
|
||||
logger.debug("communicator: #{communicator}")
|
||||
logger.debug("uploading: #{from} -> #{to}")
|
||||
|
||||
communicator.upload(from, to)
|
||||
|
||||
Empty.new
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user