Chris Roberts fe293dfd1f
Require client to be set and provide stub on initial startup
When running in server mode, make the Environment validate a client
option is provided on instantiation. If no client option is provided,
raise an exception since it is required in server mode.

Since an initial Environment is required during start, include a
stub value for the client so the initial Environment can be instantiated
successfully and the GRPC service can be started.
2022-04-25 12:24:23 -05:00

30 lines
617 B
Ruby

module Vagrant
class Environment
module Remote
def self.prepended(klass)
klass.class_eval do
attr_reader :client
end
end
def initialize(opts={})
super
@client = opts[:client]
if @client.nil?
raise ArgumentError,
"Remote client is required for `#{self.class.name}'"
end
end
# Gets a target (machine) by name
#
# @param [String] machine name
# return [VagrantPlugins::CommandServe::Client::Machine]
def get_target(name)
client.target(name)
end
end
end
end