Use path proto to pass around paths
This commit is contained in:
parent
175f05657c
commit
38dd5ef5f9
@ -70,10 +70,8 @@ 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)
|
||||
from_val = mapper.map(from, to: SDK::Args::Path)
|
||||
to_val = mapper.map(to, to: SDK::Args::Path)
|
||||
req = SDK::FuncSpec::Args.new(
|
||||
args: [
|
||||
SDK::FuncSpec::Value.new(
|
||||
@ -100,10 +98,8 @@ module VagrantPlugins
|
||||
# @param [String] local path
|
||||
# @param [String] remote path
|
||||
def upload(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)
|
||||
from_val = mapper.map(from, to: SDK::Args::Path)
|
||||
to_val = mapper.map(to, to: SDK::Args::Path)
|
||||
req = SDK::FuncSpec::Args.new(
|
||||
args: [
|
||||
SDK::FuncSpec::Value.new(
|
||||
|
||||
@ -47,6 +47,20 @@ module VagrantPlugins
|
||||
Pathname.new(path.path)
|
||||
end
|
||||
end
|
||||
|
||||
class StringToPathname < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: String)],
|
||||
output: Pathname,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(path)
|
||||
Pathname.new(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -116,9 +116,9 @@ module VagrantPlugins
|
||||
with_info(ctx) do |info|
|
||||
plugin_name = info.plugin_name
|
||||
dest_proto = req.args.select{ |a| a.name == "destination" }.first
|
||||
to = mapper.unany(dest_proto.value).to_ruby
|
||||
to = mapper.map(dest_proto.value, to: Pathname).to_s
|
||||
source_proto = req.args.select{ |a| a.name == "source" }.first
|
||||
from = mapper.unany(source_proto.value).to_ruby
|
||||
from = mapper.map(source_proto.value, to: Pathname).to_s
|
||||
req.args.reject!{ |a| a.name == "source" || a.name == "destination" }
|
||||
machine = mapper.funcspec_map(
|
||||
req, mapper, broker,
|
||||
@ -156,9 +156,9 @@ module VagrantPlugins
|
||||
with_info(ctx) do |info|
|
||||
plugin_name = info.plugin_name
|
||||
dest_proto = req.args.select{ |a| a.name == "destination" }.first
|
||||
to = mapper.unany(dest_proto.value).to_ruby
|
||||
to = mapper.map(dest_proto.value, to: Pathname).to_s
|
||||
source_proto = req.args.select{ |a| a.name == "source" }.first
|
||||
from = mapper.unany(source_proto.value).to_ruby
|
||||
from = mapper.map(source_proto.value, to: Pathname).to_s
|
||||
req.args.reject!{ |a| a.name == "source" || a.name == "destination" }
|
||||
machine = mapper.funcspec_map(
|
||||
req, mapper, broker,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user