diff --git a/builtin/myplugin/communicator_dummy.go b/builtin/myplugin/communicator_dummy.go new file mode 100644 index 000000000..d4671c3ec --- /dev/null +++ b/builtin/myplugin/communicator_dummy.go @@ -0,0 +1,116 @@ +package myplugin + +import ( + "github.com/hashicorp/vagrant-plugin-sdk/component" + plugincore "github.com/hashicorp/vagrant-plugin-sdk/core" +) + +type DummyConfig struct { +} + +// DummyCommunicator is a Communicator implementation for myplugin. +type DummyCommunicator struct { + config DummyConfig +} + +func (h *DummyCommunicator) MatchFunc() interface{} { + return h.Match +} + +func (h *DummyCommunicator) Match(machine plugincore.Machine) (isMatch bool, err error) { + return true, nil +} + +func (h *DummyCommunicator) InitFunc() interface{} { + return h.Init +} + +func (h *DummyCommunicator) Init(machine plugincore.Machine) error { + return nil +} + +func (h *DummyCommunicator) ReadyFunc() interface{} { + return h.Ready +} + +func (h *DummyCommunicator) Ready(machine plugincore.Machine) (isReady bool, err error) { + return false, nil +} + +func (h *DummyCommunicator) WaitForReadyFunc() interface{} { + return h.WaitForReady +} + +func (h *DummyCommunicator) WaitForReady(machine plugincore.Machine, wait int) (isReady bool, err error) { + return false, nil +} + +func (h *DummyCommunicator) DownloadFunc() interface{} { + return h.Download +} + +func (h *DummyCommunicator) Download( + machine plugincore.Machine, + source, destination string, +) error { + return nil +} + +func (h *DummyCommunicator) UploadFunc() interface{} { + return h.Upload +} + +func (h *DummyCommunicator) Upload( + machine plugincore.Machine, + source, destination string, +) error { + return nil +} + +func (h *DummyCommunicator) ExecuteFunc() interface{} { + return h.Execute +} + +func (h *DummyCommunicator) Execute( + machine plugincore.Machine, + command []string, + options ...CommunicatorOptions, +) (status int32, err error) { + return 0, nil +} + +func (h *DummyCommunicator) PrivilegedExecuteFunc() interface{} { + return h.PrivilegedExecute +} + +func (h *DummyCommunicator) PrivilegedExecute( + machine plugincore.Machine, + command []string, + options ...CommunicatorOptions, +) (status int32, err error) { + return 0, nil +} + +func (h *DummyCommunicator) TestFunc() interface{} { + return h.Test +} + +func (h *DummyCommunicator) Test( + machine plugincore.Machine, + command []string, + options ...CommunicatorOptions, +) (valid bool, err error) { + return true, nil +} + +func (h *DummyCommunicator) ResetFunc() interface{} { + return h.Reset +} + +func (h *DummyCommunicator) Reset(machine plugincore.Machine) (err error) { + return nil +} + +var ( + _ component.Communicator = (*DummyCommunicator)(nil) +) diff --git a/builtin/myplugin/main.go b/builtin/myplugin/main.go index 227fd8c62..e405a2324 100644 --- a/builtin/myplugin/main.go +++ b/builtin/myplugin/main.go @@ -14,6 +14,7 @@ var CommandOptions = []sdk.Option{ &Provider{}, &command.Command{}, &host.AlwaysTrueHost{}, + &DummyCommunicator{}, ), sdk.WithName("myplugin"), } diff --git a/builtin/myplugin/plugin.pb.go b/builtin/myplugin/plugin.pb.go index ecce0433c..ef1cb7e8f 100644 --- a/builtin/myplugin/plugin.pb.go +++ b/builtin/myplugin/plugin.pb.go @@ -63,6 +63,61 @@ func (*UpResult) Descriptor() ([]byte, []int) { return file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDescGZIP(), []int{0} } +type CommunicatorOptions struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + KeepAlive string `protobuf:"bytes,1,opt,name=keep_alive,json=keepAlive,proto3" json:"keep_alive,omitempty"` + Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` +} + +func (x *CommunicatorOptions) Reset() { + *x = CommunicatorOptions{} + if protoimpl.UnsafeEnabled { + mi := &file_vagrant_ruby_builtin_myplugin_plugin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommunicatorOptions) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommunicatorOptions) ProtoMessage() {} + +func (x *CommunicatorOptions) ProtoReflect() protoreflect.Message { + mi := &file_vagrant_ruby_builtin_myplugin_plugin_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CommunicatorOptions.ProtoReflect.Descriptor instead. +func (*CommunicatorOptions) Descriptor() ([]byte, []int) { + return file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDescGZIP(), []int{1} +} + +func (x *CommunicatorOptions) GetKeepAlive() string { + if x != nil { + return x.KeepAlive + } + return "" +} + +func (x *CommunicatorOptions) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + var File_vagrant_ruby_builtin_myplugin_plugin_proto protoreflect.FileDescriptor var file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDesc = []byte{ @@ -70,7 +125,12 @@ var file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDesc = []byte{ 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x6d, 0x79, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6d, 0x79, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x0a, 0x0a, 0x08, 0x55, 0x70, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x42, 0x1f, 0x5a, 0x1d, 0x76, 0x61, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2d, 0x72, 0x75, + 0x6c, 0x74, 0x22, 0x4e, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, + 0x6f, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6b, 0x65, 0x65, + 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6b, + 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, + 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x42, 0x1f, 0x5a, 0x1d, 0x76, 0x61, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2d, 0x72, 0x75, 0x62, 0x79, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x6d, 0x79, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -87,9 +147,10 @@ func file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDescGZIP() []byte { return file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDescData } -var file_vagrant_ruby_builtin_myplugin_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_vagrant_ruby_builtin_myplugin_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_vagrant_ruby_builtin_myplugin_plugin_proto_goTypes = []interface{}{ - (*UpResult)(nil), // 0: myplugin.UpResult + (*UpResult)(nil), // 0: myplugin.UpResult + (*CommunicatorOptions)(nil), // 1: myplugin.CommunicatorOptions } var file_vagrant_ruby_builtin_myplugin_plugin_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -117,6 +178,18 @@ func file_vagrant_ruby_builtin_myplugin_plugin_proto_init() { return nil } } + file_vagrant_ruby_builtin_myplugin_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommunicatorOptions); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -124,7 +197,7 @@ func file_vagrant_ruby_builtin_myplugin_plugin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vagrant_ruby_builtin_myplugin_plugin_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/builtin/myplugin/plugin.proto b/builtin/myplugin/plugin.proto index 82b449e7a..0aa8d5d9d 100644 --- a/builtin/myplugin/plugin.proto +++ b/builtin/myplugin/plugin.proto @@ -5,3 +5,8 @@ package myplugin; option go_package = "vagrant-ruby/builtin/myplugin"; message UpResult {} + +message CommunicatorOptions { + string keep_alive = 1; + int64 timeout = 2; +}