diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 91b4486ec..375452914 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -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 diff --git a/plugins/providers/docker/plugin.rb b/plugins/providers/docker/plugin.rb index 5b024519a..1558aa51d 100644 --- a/plugins/providers/docker/plugin.rb +++ b/plugins/providers/docker/plugin.rb @@ -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 diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 5de1f493e..f85339310 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -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 }]