Make go communincator plugin work
This commit is contained in:
parent
49ad851606
commit
85f7aa1586
@ -1,6 +1,8 @@
|
||||
package communicator
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-argmapper"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||
pb "github.com/hashicorp/vagrant/builtin/myplugin/proto"
|
||||
@ -61,10 +63,16 @@ func (h *DummyCommunicator) UploadFunc() interface{} {
|
||||
return h.Upload
|
||||
}
|
||||
|
||||
func (h *DummyCommunicator) Upload(
|
||||
machine plugincore.Machine,
|
||||
source string, destination string,
|
||||
func (h *DummyCommunicator) Upload(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
|
||||
}
|
||||
|
||||
@ -87,7 +95,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
|
||||
}
|
||||
|
||||
@ -95,7 +95,8 @@ func (t *Target) Communicate() (c core.Communicator, err error) {
|
||||
}
|
||||
// TODO: get the communicator name from the Vagrantfile
|
||||
// eg. t.target.Configuration.ConfigVm.Communicator
|
||||
communicatorName := "ssh"
|
||||
// communicatorName := "ssh"
|
||||
communicatorName := "myplugin"
|
||||
communicators, err := t.project.basis.typeComponents(t.ctx, component.CommunicatorType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -96,6 +96,10 @@ 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)
|
||||
req = SDK::FuncSpec::Args.new(
|
||||
args: [
|
||||
SDK::FuncSpec::Value.new(
|
||||
@ -104,15 +108,25 @@ 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",
|
||||
type: "string",
|
||||
value: Google::Protobuf::Any.pack(from_val)
|
||||
),
|
||||
SDK::FuncSpec::Value.new(
|
||||
name: "destination",
|
||||
type: "string",
|
||||
value: Google::Protobuf::Any.pack(to_val)
|
||||
),
|
||||
# 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"),
|
||||
# ])
|
||||
# ),
|
||||
# ),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user