Get all plugins

This commit is contained in:
sophia 2020-12-01 12:38:40 -06:00 committed by Paul Hinze
parent 673ffcf1b1
commit 244bb335c8
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 37 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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