Use registries for the V2 plugin manager
This commit is contained in:
parent
f3b340aae0
commit
25fcb59e38
|
@ -329,7 +329,7 @@ module Vagrant
|
|||
# will return nil, and we don't want to trigger a detect load.
|
||||
host_klass = config_global.vagrant.host
|
||||
if host_klass.nil? || host_klass == :detect
|
||||
hosts = Vagrant.plugin("2").manager.hosts
|
||||
hosts = Vagrant.plugin("2").manager.hosts.to_hash
|
||||
|
||||
# Get the flattened list of available hosts
|
||||
host_klass = Hosts.detect(hosts)
|
||||
|
|
|
@ -18,106 +18,88 @@ module Vagrant
|
|||
#
|
||||
# @return [Hash]
|
||||
def commands
|
||||
result = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.command.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.command)
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# This returns all the registered communicators.
|
||||
#
|
||||
# @return [Hash]
|
||||
def communicators
|
||||
result = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.communicator.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.communicator)
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# This returns all the registered configuration classes.
|
||||
#
|
||||
# @return [Hash]
|
||||
def config
|
||||
result = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
plugin.components.configs[:top].each do |key, klass|
|
||||
result[key] = klass
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.components.configs[:top])
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# This returns all the registered guests.
|
||||
#
|
||||
# @return [Hash]
|
||||
def guests
|
||||
result = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.guest.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.guest)
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# This returns all registered host classes.
|
||||
#
|
||||
# @return [Hash]
|
||||
def hosts
|
||||
hosts = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
hosts.merge!(plugin.host.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.host)
|
||||
end
|
||||
end
|
||||
|
||||
hosts
|
||||
end
|
||||
|
||||
# This returns all registered providers.
|
||||
#
|
||||
# @return [Hash]
|
||||
def providers
|
||||
providers = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
providers.merge!(plugin.provider.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.provider)
|
||||
end
|
||||
end
|
||||
|
||||
providers
|
||||
end
|
||||
|
||||
# This returns all the config classes for the various providers.
|
||||
#
|
||||
# @return [Hash]
|
||||
def provider_configs
|
||||
configs = Registry.new
|
||||
|
||||
@registered.each do |plugin|
|
||||
configs.merge!(plugin.components.configs[:provider])
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.components.configs[:provider])
|
||||
end
|
||||
end
|
||||
|
||||
configs
|
||||
end
|
||||
|
||||
# This returns all registered provisioners.
|
||||
#
|
||||
# @return [Hash]
|
||||
def provisioners
|
||||
results = {}
|
||||
|
||||
@registered.each do |plugin|
|
||||
results.merge!(plugin.provisioner.to_hash)
|
||||
Registry.new.tap do |result|
|
||||
@registered.each do |plugin|
|
||||
result.merge!(plugin.provisioner)
|
||||
end
|
||||
end
|
||||
|
||||
results
|
||||
end
|
||||
|
||||
# This registers a plugin. This should _NEVER_ be called by the public
|
||||
|
|
|
@ -23,7 +23,7 @@ describe Vagrant::Plugin::V2::Manager do
|
|||
instance.register(pA)
|
||||
instance.register(pB)
|
||||
|
||||
instance.communicators.length.should == 2
|
||||
instance.communicators.to_hash.length.should == 2
|
||||
instance.communicators[:foo].should == "bar"
|
||||
instance.communicators[:bar].should == "baz"
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ describe Vagrant::Plugin::V2::Manager do
|
|||
instance.register(pA)
|
||||
instance.register(pB)
|
||||
|
||||
instance.config.length.should == 2
|
||||
instance.config.to_hash.length.should == 2
|
||||
instance.config[:foo].should == "bar"
|
||||
instance.config[:bar].should == "baz"
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ describe Vagrant::Plugin::V2::Manager do
|
|||
instance.register(pA)
|
||||
instance.register(pB)
|
||||
|
||||
instance.guests.length.should == 2
|
||||
instance.guests.to_hash.length.should == 2
|
||||
instance.guests[:foo].should == "bar"
|
||||
instance.guests[:bar].should == "baz"
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ describe Vagrant::Plugin::V2::Manager do
|
|||
instance.register(pA)
|
||||
instance.register(pB)
|
||||
|
||||
instance.hosts.length.should == 2
|
||||
instance.hosts.to_hash.length.should == 2
|
||||
instance.hosts[:foo].should == "bar"
|
||||
instance.hosts[:bar].should == "baz"
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ describe Vagrant::Plugin::V2::Manager do
|
|||
instance.register(pA)
|
||||
instance.register(pB)
|
||||
|
||||
instance.providers.length.should == 2
|
||||
instance.providers.to_hash.length.should == 2
|
||||
instance.providers[:foo].should == "bar"
|
||||
instance.providers[:bar].should == "baz"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue