Initialize remote box with client
This commit is contained in:
parent
2b93a26b50
commit
80f3549716
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user