From 41f3af51af78fdc15a881ed6db351128c2dcd47b Mon Sep 17 00:00:00 2001 From: sophia Date: Fri, 8 Jan 2021 13:40:39 -0600 Subject: [PATCH] Return a result from an up action --- lib/proto/gen/plugin/plugin_server_pb.rb | 18 ++++++++++++++++++ lib/proto/plugin_server.proto | 8 ++++++++ plugins/README.md | 6 ++++++ .../commands/serve/service/provider_service.rb | 8 +++++++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lib/proto/gen/plugin/plugin_server_pb.rb create mode 100644 lib/proto/plugin_server.proto diff --git a/lib/proto/gen/plugin/plugin_server_pb.rb b/lib/proto/gen/plugin/plugin_server_pb.rb new file mode 100644 index 000000000..1c96d9a42 --- /dev/null +++ b/lib/proto/gen/plugin/plugin_server_pb.rb @@ -0,0 +1,18 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: plugin_server.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("plugin_server.proto", :syntax => :proto3) do + add_message "hashicorp.vagrant.UpResult" do + optional :success, :bool, 1 + end + end +end + +module Hashicorp + module Vagrant + UpResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.UpResult").msgclass + end +end diff --git a/lib/proto/plugin_server.proto b/lib/proto/plugin_server.proto new file mode 100644 index 000000000..5cdc5cc63 --- /dev/null +++ b/lib/proto/plugin_server.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +package hashicorp.vagrant; + +message UpResult { + bool success = 1; +} + diff --git a/plugins/README.md b/plugins/README.md index 97f6bd2ff..ffe4b3299 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -3,3 +3,9 @@ These are plugins that ship with Vagrant. Vagrant core uses its own plugin system to power a lot of the core pieces that ship with Vagrant. Each plugin will have its own README which explains its specific role. + +## Generate proto + +``` +grpc_tools_ruby_protoc -I . --ruby_out=gen/plugin --grpc_out=gen/plugin ./plugin_server.proto +``` diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index 55970aee5..9f4e4319a 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -1,6 +1,7 @@ require 'proto/gen/plugin/plugin_pb' require 'proto/gen/plugin/plugin_services_pb' +require 'proto/gen/plugin/plugin_server_pb' require 'vagrant/machine' require 'logger' @@ -37,6 +38,7 @@ module VagrantPlugins def action_up(req, _unused_call) machine = machine_arg_to_machine(req) LOG.debug(machine) + Hashicorp::Vagrant::UpResult.new(success: true) end def machine_arg_to_machine(req) @@ -60,8 +62,12 @@ module VagrantPlugins ), ] result = [ - nil, + Hashicorp::Vagrant::Sdk::FuncSpec::Value.new( + type: "hashicorp.vagrant.UpResult", + name: "" + ), ] + Hashicorp::Vagrant::Sdk::FuncSpec.new( args: args, result: result