Push plugin discovery down into command package

Previously we did plugin discovery in the main package, but as we move
towards versioned plugins we need more information available in order to
resolve plugins, so we move this responsibility into the command package
itself.

For the moment this is just preserving the existing behavior as long as
there are only internal and unversioned plugins present. This is the
final state for provisioners in 0.10, since we don't want to support
versioned provisioners yet. For providers this is just a checkpoint along
the way, since further work is required to apply version constraints from
configuration and support additional plugin search directories.

The automatic plugin discovery behavior is not desirable for tests because
we want to mock the plugins there, so we add a new backdoor for the tests
to use to skip the plugin discovery and just provide their own mock
implementations. Most of this diff is thus noisy rework of the tests to
use this new mechanism.
This commit is contained in:
Martin Atkins
2017-04-13 18:05:58 -07:00
parent bcd395e6bd
commit 8364383c35
28 changed files with 611 additions and 657 deletions

10
main.go
View File

@@ -108,10 +108,6 @@ func wrappedMain() int {
// Load the configuration
config := BuiltinConfig
if err := config.Discover(Ui); err != nil {
Ui.Error(fmt.Sprintf("Error discovering plugins: %s", err))
return 1
}
// Load the configuration file if we have one, that can be used to
// define extra providers and provisioners.
@@ -185,9 +181,9 @@ func wrappedMain() int {
HelpWriter: os.Stdout,
}
// Initialize the TFConfig settings for the commands...
ContextOpts.Providers = config.ProviderFactories()
ContextOpts.Provisioners = config.ProvisionerFactories()
// Pass in the overriding plugin paths from config
PluginOverrides.Providers = config.Providers
PluginOverrides.Provisioners = config.Provisioners
exitCode, err := cliRunner.Run()
if err != nil {