Initialize remote box with client

This commit is contained in:
sophia 2021-11-10 16:58:04 -06:00 committed by Paul Hinze
parent 2b93a26b50
commit 80f3549716
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@ module Vagrant
# disk.
# @param [String] metadata_url Metadata URL for box
# @param [Hook] hook A hook to apply to the box downloader, for example, for authentication
def initialize(name, provider, version, directory, metadata_url: nil, hook: nil)
def initialize(name, provider, version, directory, metadata_url: nil, hook: nil, client: nil)
@logger = Log4r::Logger.new("vagrant::box")
@name = name
@ -28,6 +28,12 @@ module Vagrant
@directory = directory
@metadata_url = metadata_url
@hook = hook
if client.nil?
raise ArgumentError,
"Remote client is required for `#{self.class.name}'"
end
@client = client
end
def destroy!
@ -57,10 +63,6 @@ module Vagrant
def to_proto
client.proto
end
def client=(c)
@client = c
end
end
end
end

View File

@ -19,15 +19,13 @@ module VagrantPlugins
def box
b = client.box(Empty.new)
box_client = Box.load(b, broker: broker)
logger.debug("got box client #{box_client}")
box = Vagrant::Box.new(
box_client.name,
box_client.provider.to_sym,
box_client.version,
Pathname.new(box_client.directory),
client: box_client
)
logger.debug("generate box from box client #{box}")
box.client = box_client
box
end