core: clean up default logic

This commit is contained in:
Mitchell Hashimoto 2014-10-23 15:59:27 -07:00
parent 59dbe51ef2
commit b7478e09f3
2 changed files with 7 additions and 3 deletions

View File

@ -320,7 +320,7 @@ module Vagrant
# Get the list of providers within our configuration and assign
# a priority to each in the order they exist so that we try these first.
config = {}
root_config.vm.__providers.each_with_index do |key, idx|
root_config.vm.__providers.reverse.each_with_index do |key, idx|
config[key] = idx
end
@ -340,8 +340,11 @@ module Vagrant
# Skip excluded providers
next if opts[:exclude] && opts[:exclude].include?(key)
# Skip providers that can't be defaulted
next if popts.has_key?(:defaultable) && !popts[:defaultable]
# Skip providers that can't be defaulted, unless they're in our
# config, in which case someone made our decision for us.
if !config.has_key?(key)
next if popts.has_key?(:defaultable) && !popts[:defaultable]
end
# The priority is higher if it is in our config. Otherwise, it is
# the priority it set PLUS the length of the config to make sure it

View File

@ -810,6 +810,7 @@ VF
it "is the provider in the Vagrantfile that is usable" do
subject.vagrantfile.config.vm.provider "foo"
subject.vagrantfile.config.vm.provider "bar"
subject.vagrantfile.config.vm.finalize!
plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]