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.
This commit is contained in:
parent
3ca9519f5c
commit
fe293dfd1f
@ -197,6 +197,12 @@ begin
|
||||
# Check if we are running the server
|
||||
if sub_cmd == "serve"
|
||||
Vagrant.enable_server_mode!
|
||||
# NOTE: We stub the client option to allow the environment to
|
||||
# be initialized for startup since it will raise an
|
||||
# exception if it is unset. We don't care about the
|
||||
# initially created environment, we just need it long
|
||||
# enough for our serve command to get executed.
|
||||
opts[:client] = :stub
|
||||
end
|
||||
|
||||
# Create the environment, which is the cwd of wherever the
|
||||
|
||||
@ -11,6 +11,10 @@ module Vagrant
|
||||
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
|
||||
@ -18,7 +22,7 @@ module Vagrant
|
||||
# @param [String] machine name
|
||||
# return [VagrantPlugins::CommandServe::Client::Machine]
|
||||
def get_target(name)
|
||||
return @client.target(name)
|
||||
client.target(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user