From 6d397a072de42703a0c87c4446e9917e47ce937f Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 6 Jan 2021 11:59:22 -0600 Subject: [PATCH] Add provider service --- plugins/commands/serve/command.rb | 6 ++- .../proto/gen/plugin/core_services_pb.rb | 2 +- .../service/proto/gen/plugin/plugin_pb.rb | 4 +- .../proto/gen/plugin/plugin_services_pb.rb | 2 +- .../proto/gen/plugin/protostructure_pb.rb | 42 ++++++++++++++++++ .../serve/service/provider_service.rb | 43 +++++++++++++++++++ 6 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 plugins/commands/serve/service/proto/gen/plugin/protostructure_pb.rb create mode 100644 plugins/commands/serve/service/provider_service.rb diff --git a/plugins/commands/serve/command.rb b/plugins/commands/serve/command.rb index 79284bb0f..806c8bde5 100644 --- a/plugins/commands/serve/command.rb +++ b/plugins/commands/serve/command.rb @@ -1,4 +1,6 @@ require_relative "./service/plugin_service" +require_relative "./service/provider_service" + require "optparse" require 'grpc' require 'grpc/health/checker' @@ -43,7 +45,9 @@ module VagrantPlugins s.add_http2_port("[::]:#{port}", :this_port_is_insecure) s.handle(VagrantPlugins::CommandServe::Serve::PluginService.new) - + s.handle(VagrantPlugins::CommandServe::Serve::ProviderService.new) + + health_checker = Grpc::Health::Checker.new health_checker.add_status( "Service::PluginService", diff --git a/plugins/commands/serve/service/proto/gen/plugin/core_services_pb.rb b/plugins/commands/serve/service/proto/gen/plugin/core_services_pb.rb index 7297857c8..6796f23c9 100644 --- a/plugins/commands/serve/service/proto/gen/plugin/core_services_pb.rb +++ b/plugins/commands/serve/service/proto/gen/plugin/core_services_pb.rb @@ -2,7 +2,7 @@ # Source: core.proto for package 'hashicorp.vagrant.sdk' require 'grpc' -require 'core_pb' +require_relative './core_pb' module Hashicorp module Vagrant diff --git a/plugins/commands/serve/service/proto/gen/plugin/plugin_pb.rb b/plugins/commands/serve/service/proto/gen/plugin/plugin_pb.rb index e15dbb213..56c758a47 100644 --- a/plugins/commands/serve/service/proto/gen/plugin/plugin_pb.rb +++ b/plugins/commands/serve/service/proto/gen/plugin/plugin_pb.rb @@ -6,8 +6,8 @@ require 'google/protobuf' require 'google/protobuf/any_pb' require 'google/protobuf/empty_pb' require 'google/rpc/status_pb' -require 'protostructure_pb' -require 'core_pb' +require_relative './protostructure_pb' +require_relative './core_pb' Google::Protobuf::DescriptorPool.generated_pool.build do add_file("plugin.proto", :syntax => :proto3) do add_message "hashicorp.vagrant.sdk.Args" do diff --git a/plugins/commands/serve/service/proto/gen/plugin/plugin_services_pb.rb b/plugins/commands/serve/service/proto/gen/plugin/plugin_services_pb.rb index d9db2a44d..b0b43b740 100644 --- a/plugins/commands/serve/service/proto/gen/plugin/plugin_services_pb.rb +++ b/plugins/commands/serve/service/proto/gen/plugin/plugin_services_pb.rb @@ -2,7 +2,7 @@ # Source: plugin.proto for package 'hashicorp.vagrant.sdk' require 'grpc' -require 'plugin_pb' +require_relative './plugin_pb' module Hashicorp module Vagrant diff --git a/plugins/commands/serve/service/proto/gen/plugin/protostructure_pb.rb b/plugins/commands/serve/service/proto/gen/plugin/protostructure_pb.rb new file mode 100644 index 000000000..9b2a9c0c1 --- /dev/null +++ b/plugins/commands/serve/service/proto/gen/plugin/protostructure_pb.rb @@ -0,0 +1,42 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: protostructure.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("protostructure.proto", :syntax => :proto3) do + add_message "protostructure.Struct" do + repeated :fields, :message, 1, "protostructure.Struct.Field" + end + add_message "protostructure.Struct.Field" do + optional :Name, :string, 1 + optional :PkgPath, :string, 2 + optional :Tag, :string, 3 + optional :type, :message, 4, "protostructure.Type" + end + add_message "protostructure.Type" do + oneof :type do + optional :primitive, :message, 1, "protostructure.Primitive" + optional :container, :message, 2, "protostructure.Container" + optional :struct, :message, 3, "protostructure.Struct" + end + end + add_message "protostructure.Primitive" do + optional :kind, :uint32, 1 + end + add_message "protostructure.Container" do + optional :kind, :uint32, 1 + optional :elem, :message, 2, "protostructure.Type" + optional :key, :message, 3, "protostructure.Type" + optional :count, :int32, 4 + end + end +end + +module Protostructure + Struct = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("protostructure.Struct").msgclass + Struct::Field = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("protostructure.Struct.Field").msgclass + Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("protostructure.Type").msgclass + Primitive = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("protostructure.Primitive").msgclass + Container = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("protostructure.Container").msgclass +end diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb new file mode 100644 index 000000000..13fac1e41 --- /dev/null +++ b/plugins/commands/serve/service/provider_service.rb @@ -0,0 +1,43 @@ + +require_relative 'proto/gen/plugin/plugin_pb' +require_relative 'proto/gen/plugin/plugin_services_pb' + +module VagrantPlugins + module CommandServe + module Serve + class ProviderService < Hashicorp::Vagrant::Sdk::ProviderService::Service + def usable(req, _unused_call) + nil + end + + def usable_spec(req, _unused_call) + nil + end + + def installed(req, _unused_call) + nil + end + + def installed_spec(req, _unused_call) + nil + end + + def init(req, _unused_call) + nil + end + + def init_spec(req, _unused_call) + nil + end + + def action_up(req, _unused_call) + nil + end + + def action_up_spec(req, _unused_call) + nil + end + end + end + end +end