Merge pull request #10155 from chrisroberts/f-plugin-load-config

Reset internal environment after plugin load
This commit is contained in:
Chris Roberts 2018-08-30 11:30:14 -07:00 committed by GitHub
commit e24728cb5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) { {} }