diff --git a/lib/vagrant/action/builtin/remote/mixin_synced_folders.rb b/lib/vagrant/action/builtin/remote/mixin_synced_folders.rb index 8bd5a97d2..d0e843390 100644 --- a/lib/vagrant/action/builtin/remote/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/remote/mixin_synced_folders.rb @@ -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 diff --git a/lib/vagrant/plugin/remote/manager.rb b/lib/vagrant/plugin/remote/manager.rb index 0e6cd27b1..771c17445 100644 --- a/lib/vagrant/plugin/remote/manager.rb +++ b/lib/vagrant/plugin/remote/manager.rb @@ -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] diff --git a/lib/vagrant/plugin/v2/plugin.rb b/lib/vagrant/plugin/v2/plugin.rb index 950d0a910..afa009020 100644 --- a/lib/vagrant/plugin/v2/plugin.rb +++ b/lib/vagrant/plugin/v2/plugin.rb @@ -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