Reset internal environment after plugin load

Force the vagrantfile and configuration loader to be rebuilt after
plugins have been loaded to properly allow newly introduced plugin
configurations to be properly supported within the Vagrantfile.
This commit is contained in:
Chris Roberts 2018-08-30 10:44:09 -07:00
parent 4974c14845
commit 9b67655e45
2 changed files with 23 additions and 0 deletions

View File

@ -178,6 +178,10 @@ module Vagrant
plugins = Vagrant::Plugin::Manager.instance.globalize!
Vagrant::Plugin::Manager.instance.load_plugins(plugins)
# Reset so Vagrantfile will be reloaded with expected support for
# any new plugins provided
post_plugins_reset!
# Call the hooks that does not require configurations to be loaded
# by using a "clean" action runner
hook(:environment_plugins_loaded, runner: Action::Runner.new(env: self))
@ -913,6 +917,18 @@ module Vagrant
protected
# Unsets the internal vagrantfile and config_loader
# to force them to be regenerated. This is used after
# plugins have been loaded so that newly discovered
# plugin configurations are properly available
#
# @return [nil]
def post_plugins_reset!
@vagrantfile = nil
@config_loader = nil
nil
end
# Check for any local plugins defined within the Vagrantfile. If
# found, validate they are available. If they are not available,
# request to install them, or raise an exception

View File

@ -25,6 +25,13 @@ describe Vagrant::Environment do
let(:instance) { env.create_vagrant_env }
subject { instance }
describe "#initialize" do
it "should do an internal reset after plugin loading" do
expect_any_instance_of(described_class).to receive(:post_plugins_reset!)
instance
end
end
describe "#can_install_provider?" do
let(:plugin_hosts) { {} }
let(:plugin_host_caps) { {} }