core: providers can choose to not be defaultable [GH-3742]
This commit is contained in:
parent
782c3762cc
commit
ca6e2393bd
|
@ -276,6 +276,9 @@ module Vagrant
|
||||||
# Skip excluded providers
|
# Skip excluded providers
|
||||||
next if opts[:exclude] && opts[:exclude].include?(key)
|
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]
|
ordered << [popts[:priority], key, impl, popts]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ module VagrantPlugins
|
||||||
Docker containers.
|
Docker containers.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
provider(:docker, box_optional: true, parallel: true, priority: 3) do
|
provider(:docker, box_optional: true, parallel: true, defaultable: false) do
|
||||||
require_relative 'provider'
|
require_relative 'provider'
|
||||||
init!
|
init!
|
||||||
Provider
|
Provider
|
||||||
|
|
|
@ -724,6 +724,17 @@ VF
|
||||||
end
|
end
|
||||||
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
|
it "is the highest matching usable provider that isn't excluded" do
|
||||||
plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]
|
plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]
|
||||||
plugin_providers[:bar] = [provider_usable_class(true), { priority: 7 }]
|
plugin_providers[:bar] = [provider_usable_class(true), { priority: 7 }]
|
||||||
|
|
Loading…
Reference in New Issue