Inject dummy client into remote synced folders

This commit is contained in:
sophia 2021-12-06 16:16:11 -06:00 committed by Paul Hinze
parent 05bbd9ec50
commit 94a203efc9
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 41 additions and 1 deletions

View File

@ -13,6 +13,12 @@ module Vagrant
end
end
# This returns the available synced folder implementations. This
# is a separate method so that it can be easily stubbed by tests.
def plugins
@plugins ||= Vagrant.plugin("remote").manager.synced_folders
end
# This should never be called?
def default_synced_folder_type(machine, plugins)
nil

View File

@ -9,12 +9,43 @@ module Vagrant
class Manager < Vagrant::Plugin::V2::Manager
attr_reader :registered
def initialize()
def initialize
@logger = Log4r::Logger.new("vagrant::plugin::remote::manager")
@logger.debug("initializing remote manager")
# Copy in local Ruby registered plugins
@registered = Vagrant.plugin("2").manager.registered
end
# This returns all synced folder implementations.
#
# @return [Registry]
def synced_folders
Registry.new.tap do |result|
@registered.each do |plugin|
plugin.components.synced_folders.each do |k, v|
sf_class = Class.new(v[0])
sf_class.class_eval do
def initialize(*_, **_)
super(@@client)
end
def self.client=(val)
@@client=val
end
def self.client
@@client
end
end
# TODO: set the actual client
sf_class.client = "todo"
v = [sf_class] + v[1..]
result.register(k) do
v
end
end
end
end
end
# Registers remote plugins provided from the client
#
# @param [VagrantPlugin::Command::Serve::Client::Basis]

View File

@ -24,9 +24,12 @@ module Vagrant
#
# @return [V2::Manager]
def self.manager
@manager if !@manager.nil?
if Vagrant.server_mode?
LOGGER.debug("using remote manager")
@manager ||= Vagrant::Plugin::Remote::Manager.new
else
LOGGER.debug("using v2 manager")
@manager ||= Manager.new
end
@manager