Enable box collection for server mode
This commit is contained in:
parent
fd0df0865c
commit
8ead293836
@ -17,6 +17,8 @@ module Vagrant
|
||||
VAGRANT_SLASH = "-VAGRANTSLASH-".freeze
|
||||
VAGRANT_COLON = "-VAGRANTCOLON-".freeze
|
||||
|
||||
autoload :Remote, "vagrant/box_collection/remote"
|
||||
|
||||
# The directory where the boxes in this collection are stored.
|
||||
#
|
||||
# A box collection matches a very specific folder structure that Vagrant
|
||||
|
||||
51
lib/vagrant/box_collection/remote.rb
Normal file
51
lib/vagrant/box_collection/remote.rb
Normal file
@ -0,0 +1,51 @@
|
||||
module Vagrant
|
||||
class BoxCollection
|
||||
# This module enables the BoxCollection for server mode
|
||||
module Remote
|
||||
|
||||
# Add an attribute reader for the client
|
||||
# when applied to the BoxCollection class
|
||||
def self.prepended(klass)
|
||||
klass.class_eval do
|
||||
attr_reader :client
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(directory, options=nil)
|
||||
@client = options[:client]
|
||||
if @client.nil?
|
||||
raise ArgumentError,
|
||||
"Remote client is required for `#{self.class.name}'"
|
||||
end
|
||||
|
||||
@directory = directory
|
||||
@hook = options[:hook]
|
||||
@logger = Log4r::Logger.new("vagrant::box_collection")
|
||||
end
|
||||
|
||||
# @return [Vagrant::Box]
|
||||
def add(path, name, version, **opts)
|
||||
client.add(
|
||||
path, name, version, force: opts[:force],
|
||||
metadata_url: opts[:metadata_url], provider:opts[:providers]
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
# @return [Array] Array of `[name, version, provider]` of the boxes
|
||||
# installed on this system.
|
||||
def all
|
||||
client.all
|
||||
end
|
||||
|
||||
# @return [Box] The box found, or `nil` if not found.
|
||||
def find(name, providers, version)
|
||||
client.find(name, providers, version)
|
||||
end
|
||||
|
||||
def clean(name)
|
||||
client.clean(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -254,6 +254,7 @@ module Vagrant
|
||||
|
||||
SERVER_MODE_CALLBACKS = [
|
||||
->{ Vagrant::Box.prepend(Vagrant::Box::Remote) },
|
||||
->{ Vagrant::BoxCollection.prepend(Vagrant::BoxCollection::Remote) },
|
||||
->{ Vagrant::Guest.prepend(Vagrant::Guest::Remote) },
|
||||
->{ Vagrant::Host.prepend(Vagrant::Host::Remote) },
|
||||
->{ Vagrant::Machine.prepend(Vagrant::Machine::Remote) },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user