core: providers can choose to not be defaultable [GH-3742]

This commit is contained in:
Mitchell Hashimoto 2014-05-09 16:02:09 -07:00
parent 782c3762cc
commit ca6e2393bd
3 changed files with 15 additions and 1 deletions

View File

@ -276,6 +276,9 @@ 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]
ordered << [popts[:priority], key, impl, popts]
end

View File

@ -16,7 +16,7 @@ module VagrantPlugins
Docker containers.
EOF
provider(:docker, box_optional: true, parallel: true, priority: 3) do
provider(:docker, box_optional: true, parallel: true, defaultable: false) do
require_relative 'provider'
init!
Provider

View File

@ -724,6 +724,17 @@ VF
end
end
it "is the highest matching usable provider that is defaultable" do
plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]
plugin_providers[:bar] = [
provider_usable_class(true), { defaultable: false, priority: 7 }]
plugin_providers[:baz] = [provider_usable_class(true), { priority: 2 }]
with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do
expect(subject.default_provider).to eq(:foo)
end
end
it "is the highest matching usable provider that isn't excluded" do
plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]
plugin_providers[:bar] = [provider_usable_class(true), { priority: 7 }]