Each component client stores their proto

This commit is contained in:
sophia 2021-08-24 13:41:15 -05:00 committed by Paul Hinze
parent 83a080521e
commit 5d46b93a99
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
9 changed files with 39 additions and 12 deletions

View File

@ -99,6 +99,10 @@ module Vagrant
end
@vagrantfile
end
def to_proto
client.proto
end
end
end
end

View File

@ -63,6 +63,10 @@ module Vagrant
def name
client.parents[0]
end
def to_proto
client.proto
end
end
end
end

View File

@ -141,6 +141,10 @@ module Vagrant
@logger.debug("machines: #{@machines.keys}")
@machines.each_value(&block)
end
def to_proto
client.proto
end
end
end
end

View File

@ -7,18 +7,21 @@ module VagrantPlugins
extend Util::Connector
attr_reader :broker
attr_reader :client
attr_reader :proto
def initialize(conn, broker=nil)
def initialize(conn, proto, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::guest")
@logger.debug("connecting to guest service on #{conn}")
@client = SDK::GuestService::Stub.new(conn, :this_channel_is_insecure)
@broker = broker
@proto = proto
end
def self.load(raw_guest, broker:)
g = raw_guest.is_a?(String) ? SDK::Args::Guest.decode(raw_guest) : raw_guest
self.new(connect(proto: g, broker: broker), broker)
self.new(connect(proto: g, broker: broker), g, broker)
end
# @return [<String>] parents

View File

@ -8,14 +8,16 @@ module VagrantPlugins
extend Util::Connector
attr_reader :broker
attr_reader :client
attr_reader :proto
def initialize(conn, proto, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::machine")
@logger.debug("connecting to target machine service on #{conn}")
@client = SDK::TargetMachineService::Stub.new(conn, :this_channel_is_insecure)
@proto = proto
@broker = broker
@proto = proto
end
def self.load(raw_machine, broker:)

View File

@ -6,17 +6,19 @@ module VagrantPlugins
attr_reader :broker
attr_reader :client
attr_reader :proto
def initialize(conn, broker=nil)
def initialize(conn, proto, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::project")
@logger.debug("connecting to project service on #{conn}")
@client = SDK::ProjectService::Stub.new(conn, :this_channel_is_insecure)
@broker = broker
@proto = proto
end
def self.load(raw_project, broker:)
p = raw_project.is_a?(String) ? SDK::Args::Project.decode(raw_project) : raw_project
self.new(connect(proto: p, broker: broker), broker)
self.new(connect(proto: p, broker: broker), p, broker)
end
# return [String]

View File

@ -16,17 +16,19 @@ module VagrantPlugins
attr_reader :broker
attr_reader :client
attr_reader :proto
def initialize(conn, broker=nil)
def initialize(conn, proto, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::target")
@logger.debug("connecting to target on #{conn}")
@client = SDK::TargetService::Stub.new(conn, :this_channel_is_insecure)
@broker = broker
@proto = proto
end
def self.load(raw_target, broker:)
t = raw_target.is_a?(String) ? SDK::Args::Target.decode(raw_target) : raw_target
self.new(connect(proto: t, broker: broker), broker)
self.new(connect(proto: t, broker: broker), t, broker)
end
# @return [SDK::Ref::Target] proto reference for this target

View File

@ -5,19 +5,21 @@ module VagrantPlugins
extend Util::Connector
attr_reader :client
attr_reader :broker
attr_reader :client
attr_reader :proto
def initialize(conn, broker=nil)
def initialize(conn, proto, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::targetindex")
@logger.debug("connecting to target index service on #{conn}")
@client = SDK::TargetIndexService::Stub.new(conn, :this_channel_is_insecure)
@broker = broker
@proto = proto
end
def self.load(raw_index, broker:)
m = raw_index.is_a?(String) ? SDK::Args::TargetIndex.decode(raw_index) : raw_index
self.new(connect(proto: m, broker: broker), broker)
self.new(connect(proto: m, broker: broker), m, broker)
end
# @param [string]

View File

@ -7,16 +7,20 @@ module VagrantPlugins
class Terminal
extend Util::Connector
attr_reader :broker
attr_reader :client
attr_reader :proto
# @params [String] endpoint for the core service
def initialize(server_endpoint)
def initialize(server_endpoint, proto, broker=nil)
@client = SDK::TerminalUIService::Stub.new(server_endpoint, :this_channel_is_insecure)
@broker = broker
@proto = proto
end
def self.load(raw_terminal, broker:)
t = raw_terminal.is_a?(String) ? SDK::Args::TerminalUI.decode(raw_terminal) : raw_terminal
self.new(connect(proto: t, broker: broker))
self.new(connect(proto: t, broker: broker), t, broker)
end
# @param [Array] lines Lines to print