create a new InternalProviders test
Remove the legacy InternalProviders global. The terraform provider is the only one run internally.
This commit is contained in:
parent
18975d7270
commit
5a9e0cf763
|
@ -45,16 +45,6 @@ func (c *InternalPluginCommand) Run(args []string) int {
|
||||||
log.SetPrefix(fmt.Sprintf("%s-%s (internal) ", pluginName, pluginType))
|
log.SetPrefix(fmt.Sprintf("%s-%s (internal) ", pluginName, pluginType))
|
||||||
|
|
||||||
switch 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":
|
case "provisioner":
|
||||||
pluginFunc, found := InternalProvisioners[pluginName]
|
pluginFunc, found := InternalProvisioners[pluginName]
|
||||||
if !found {
|
if !found {
|
||||||
|
|
|
@ -14,8 +14,6 @@ import (
|
||||||
"github.com/hashicorp/terraform/plugin"
|
"github.com/hashicorp/terraform/plugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var InternalProviders = map[string]plugin.ProviderFunc{}
|
|
||||||
|
|
||||||
var InternalProvisioners = map[string]plugin.ProvisionerFunc{
|
var InternalProvisioners = map[string]plugin.ProvisionerFunc{
|
||||||
"chef": chefprovisioner.Provisioner,
|
"chef": chefprovisioner.Provisioner,
|
||||||
"file": fileprovisioner.Provisioner,
|
"file": fileprovisioner.Provisioner,
|
||||||
|
|
|
@ -2,15 +2,26 @@ package command
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
// providers are all external for now
|
func TestInternalPlugin_InternalProviders(t *testing.T) {
|
||||||
//func TestInternalPlugin_InternalProviders(t *testing.T) {
|
m := new(Meta)
|
||||||
// // Note this is a randomish sample and does not check for all plugins
|
providers := m.internalProviders()
|
||||||
// for _, name := range []string{"atlas", "consul", "docker", "template"} {
|
// terraform is the only provider moved back to internal
|
||||||
// if _, ok := InternalProviders[name]; !ok {
|
for _, name := range []string{"terraform"} {
|
||||||
// t.Errorf("Expected to find %s in InternalProviders", name)
|
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) {
|
func TestInternalPlugin_InternalProvisioners(t *testing.T) {
|
||||||
for _, name := range []string{"chef", "file", "local-exec", "remote-exec", "salt-masterless"} {
|
for _, name := range []string{"chef", "file", "local-exec", "remote-exec", "salt-masterless"} {
|
||||||
|
|
Loading…
Reference in New Issue