Merge pull request #13031 from chrisroberts/redux-eol-macos

Isolate protobuf message loading to server mode
This commit is contained in:
Chris Roberts 2023-03-15 15:05:44 -07:00 committed by GitHub
commit b77fb6ab4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 20 deletions

View File

@ -45,21 +45,6 @@ require "rubygems"
require "vagrant/util"
require "vagrant/plugin/manager"
# Update the load path so our protos can be located
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs").to_s
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto").to_s
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto/vagrant_plugin_sdk").to_s
# Load our protos so they are available
require 'vagrant/protobufs/proto/vagrant_server/server_pb'
require 'vagrant/protobufs/proto/vagrant_server/server_services_pb'
require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_pb'
require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_services_pb'
require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_pb'
require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_services_pb'
require 'vagrant/protobufs/proto/plugin/grpc_broker_pb'
require 'vagrant/protobufs/proto/plugin/grpc_broker_services_pb'
# Enable logging if it is requested. We do this before
# anything else so that we can setup the output before
# any logging occurs.

View File

@ -15,11 +15,6 @@ module Vagrant
UNSET_VALUE = :__UNSET__VALUE__
if Vagrant.server_mode?
GENERAL_CONFIG_CLS = Hashicorp::Vagrant::Sdk::Vagrantfile::GeneralConfig
SYMBOL_PROTO = Hashicorp::Vagrant::Sdk::Args::Symbol
end
# This is called as a last-minute hook that allows the configuration
# object to finalize itself before it will be put into use. This is
# a useful place to do some defaults in the case the user didn't

View File

@ -235,6 +235,7 @@ module Vagrant
# @return [true]
def self.enable_server_mode!
if !server_mode?
load_vagrant_proto!
SERVER_MODE_CALLBACKS.each(&:call)
Util::HCLogOutputter.new("hclog")
Log4r::Outputter["hclog"].formatter = Util::HCLogFormatter.new
@ -257,6 +258,26 @@ module Vagrant
@_server_mode = true
end
# Load the vagrant proto messages
def self.load_vagrant_proto!
return if @_vagrant_proto_loaded
# Update the load path so our protos can be located
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs").to_s
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto").to_s
$LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto/vagrant_plugin_sdk").to_s
# Load our protos so they are available
require 'vagrant/protobufs/proto/vagrant_server/server_pb'
require 'vagrant/protobufs/proto/vagrant_server/server_services_pb'
require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_pb'
require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_services_pb'
require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_pb'
require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_services_pb'
require 'vagrant/protobufs/proto/plugin/grpc_broker_pb'
require 'vagrant/protobufs/proto/plugin/grpc_broker_services_pb'
@_vagrant_proto_loaded = true
end
SERVER_MODE_CALLBACKS = [
->{ Vagrant::Box.prepend(Vagrant::Box::Remote) },
->{ Vagrant::BoxCollection.prepend(Vagrant::BoxCollection::Remote) },

View File

@ -13,6 +13,9 @@ require "vagrant/util/platform"
# Include patches for fake ftp
require "vagrant/patches/fake_ftp"
# Be sure our proto messages are available
Vagrant.load_vagrant_proto!
# Add the test directory to the load path
$:.unshift File.expand_path("../../", __FILE__)