diff --git a/plugins/commands/serve/service/plugin_service.rb b/plugins/commands/serve/service/plugin_service.rb index b32aceaa8..f6309e366 100644 --- a/plugins/commands/serve/service/plugin_service.rb +++ b/plugins/commands/serve/service/plugin_service.rb @@ -1,4 +1,4 @@ -require "vagrant/plugin/manager" +require "vagrant/plugin/v2/plugin" require_relative 'proto/gen/ruby-server_pb' require_relative 'proto/gen/ruby-server_services_pb' @@ -8,10 +8,31 @@ module VagrantPlugins module Serve class PluginService < Hashicorp::Vagrant::RubyVagrant::Service def get_plugins(req, _unused_call) - installed_plugins = Vagrant::Plugin::Manager.instance.installed_plugins - ruby_plugins = installed_plugins.map { |k, v| Hashicorp::Vagrant::Plugin.new(name: k) } + plugins = [] + plugin_manager = Vagrant::Plugin::V2::Plugin.manager + plugin_manager.commands.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::COMMAND ) + end + plugin_manager.communicators.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::COMMUNICATOR ) + end + plugin_manager.guests.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::GUEST ) + end + plugin_manager.hosts.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::HOST ) + end + plugin_manager.providers.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::PROVIDER ) + end + plugin_manager.provisioners.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::PROVISIONER ) + end + plugin_manager.synced_folders.each do |k, v| + plugins << Hashicorp::Vagrant::Plugin.new(name: k, type: Hashicorp::Vagrant::Plugin::Type::SYNCED_FOLDER ) + end Hashicorp::Vagrant::GetPluginsResponse.new( - plugins: ruby_plugins + plugins: plugins ) end end diff --git a/plugins/commands/serve/service/proto/gen/ruby-server_pb.rb b/plugins/commands/serve/service/proto/gen/ruby-server_pb.rb index 449a6b006..cfff7ad66 100644 --- a/plugins/commands/serve/service/proto/gen/ruby-server_pb.rb +++ b/plugins/commands/serve/service/proto/gen/ruby-server_pb.rb @@ -6,29 +6,29 @@ require 'google/protobuf' require 'google/protobuf/empty_pb' Google::Protobuf::DescriptorPool.generated_pool.build do add_file("internal/server/proto/ruby-server.proto", :syntax => :proto3) do - add_message "hashicorp.vagrant.RubyRef" do - end - add_message "hashicorp.vagrant.RubyRef.Plugin" do - optional :plugin, :string, 1 - end - add_message "hashicorp.vagrant.GetPluginsRequest" do - optional :plugin, :message, 1, "hashicorp.vagrant.RubyRef.Plugin" - end add_message "hashicorp.vagrant.GetPluginsResponse" do repeated :plugins, :message, 1, "hashicorp.vagrant.Plugin" end add_message "hashicorp.vagrant.Plugin" do optional :name, :string, 1 + optional :type, :enum, 2, "hashicorp.vagrant.Plugin.Type" + end + add_enum "hashicorp.vagrant.Plugin.Type" do + value :COMMAND, 0 + value :COMMUNICATOR, 1 + value :GUEST, 2 + value :HOST, 3 + value :PROVIDER, 4 + value :PROVISIONER, 5 + value :SYNCED_FOLDER, 6 end end end module Hashicorp module Vagrant - RubyRef = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.RubyRef").msgclass - RubyRef::Plugin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.RubyRef.Plugin").msgclass - GetPluginsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.GetPluginsRequest").msgclass GetPluginsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.GetPluginsResponse").msgclass Plugin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Plugin").msgclass + Plugin::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Plugin.Type").enummodule end end diff --git a/plugins/commands/serve/service/proto/gen/ruby-server_services_pb.rb b/plugins/commands/serve/service/proto/gen/ruby-server_services_pb.rb index 285440c26..e7fc2996c 100644 --- a/plugins/commands/serve/service/proto/gen/ruby-server_services_pb.rb +++ b/plugins/commands/serve/service/proto/gen/ruby-server_services_pb.rb @@ -2,7 +2,7 @@ # Source: internal/server/proto/ruby-server.proto for package 'hashicorp.vagrant' require 'grpc' -require_relative 'ruby-server_pb' +require_relative './ruby-server_pb' module Hashicorp module Vagrant