create a new InternalProviders test

Remove the legacy InternalProviders global.

The terraform provider is the only one run internally.
This commit is contained in:
James Bardin 2018-01-05 10:59:30 -05:00
parent 18975d7270
commit 5a9e0cf763
3 changed files with 20 additions and 21 deletions

View File

@ -45,16 +45,6 @@ func (c *InternalPluginCommand) Run(args []string) int {
log.SetPrefix(fmt.Sprintf("%s-%s (internal) ", pluginName, pluginType))
switch pluginType {
case "provider":
pluginFunc, found := InternalProviders[pluginName]
if !found {
log.Printf("[ERROR] Could not load provider: %s", pluginName)
return 1
}
log.Printf("[INFO] Starting provider plugin %s", pluginName)
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: pluginFunc,
})
case "provisioner":
pluginFunc, found := InternalProvisioners[pluginName]
if !found {

View File

@ -14,8 +14,6 @@ import (
"github.com/hashicorp/terraform/plugin"
)
var InternalProviders = map[string]plugin.ProviderFunc{}
var InternalProvisioners = map[string]plugin.ProvisionerFunc{
"chef": chefprovisioner.Provisioner,
"file": fileprovisioner.Provisioner,

View File

@ -2,15 +2,26 @@ package command
import "testing"
// providers are all external for now
//func TestInternalPlugin_InternalProviders(t *testing.T) {
// // Note this is a randomish sample and does not check for all plugins
// for _, name := range []string{"atlas", "consul", "docker", "template"} {
// if _, ok := InternalProviders[name]; !ok {
// t.Errorf("Expected to find %s in InternalProviders", name)
// }
// }
//}
func TestInternalPlugin_InternalProviders(t *testing.T) {
m := new(Meta)
providers := m.internalProviders()
// terraform is the only provider moved back to internal
for _, name := range []string{"terraform"} {
pf, ok := providers[name]
if !ok {
t.Errorf("Expected to find %s in InternalProviders", name)
}
provider, err := pf()
if err != nil {
t.Fatal(err)
}
if provider == nil {
t.Fatal("provider factory returned a nil provider")
}
}
}
func TestInternalPlugin_InternalProvisioners(t *testing.T) {
for _, name := range []string{"chef", "file", "local-exec", "remote-exec", "salt-masterless"} {