From cde458d74f39d35381c171f902cfb83570bbe1f5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 22 Dec 2016 18:17:49 -0800 Subject: [PATCH] scripts: update tests for generate plugins to pass new style --- scripts/generate-plugins.go | 9 +++++++++ scripts/generate-plugins_test.go | 23 ++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/scripts/generate-plugins.go b/scripts/generate-plugins.go index a10f1da6e..07bf33be7 100644 --- a/scripts/generate-plugins.go +++ b/scripts/generate-plugins.go @@ -270,6 +270,9 @@ import ( IMPORTS "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" + + // Legacy, will remove once it conforms with new structure + chefprovisioner "github.com/hashicorp/terraform/builtin/provisioners/chef" ) var InternalProviders = map[string]plugin.ProviderFunc{ @@ -280,4 +283,10 @@ var InternalProvisioners = map[string]plugin.ProvisionerFunc{ PROVISIONERS } +func init() { + // Legacy provisioners that don't match our heuristics for auto-finding + // built-in provisioners. + InternalProvisioners["chef"] = func() terraform.ResourceProvisioner { return new(chefprovisioner.ResourceProvisioner) } +} + ` diff --git a/scripts/generate-plugins_test.go b/scripts/generate-plugins_test.go index bbb3fce18..5979ee28f 100644 --- a/scripts/generate-plugins_test.go +++ b/scripts/generate-plugins_test.go @@ -7,29 +7,29 @@ func TestMakeProvisionerMap(t *testing.T) { { Package: "file", PluginName: "file", - TypeName: "ResourceProvisioner", + TypeName: "Provisioner", Path: "builtin/provisioners/file", - ImportName: "fileresourceprovisioner", + ImportName: "fileprovisioner", }, { Package: "localexec", PluginName: "local-exec", - TypeName: "ResourceProvisioner", + TypeName: "Provisioner", Path: "builtin/provisioners/local-exec", - ImportName: "localexecresourceprovisioner", + ImportName: "localexecprovisioner", }, { Package: "remoteexec", PluginName: "remote-exec", - TypeName: "ResourceProvisioner", + TypeName: "Provisioner", Path: "builtin/provisioners/remote-exec", - ImportName: "remoteexecresourceprovisioner", + ImportName: "remoteexecprovisioner", }, }) - expected := ` "file": func() terraform.ResourceProvisioner { return new(fileresourceprovisioner.ResourceProvisioner) }, - "local-exec": func() terraform.ResourceProvisioner { return new(localexecresourceprovisioner.ResourceProvisioner) }, - "remote-exec": func() terraform.ResourceProvisioner { return new(remoteexecresourceprovisioner.ResourceProvisioner) }, + expected := ` "file": fileprovisioner.Provisioner, + "local-exec": localexecprovisioner.Provisioner, + "remote-exec": remoteexecprovisioner.Provisioner, ` if p != expected { @@ -86,13 +86,10 @@ func TestDiscoverTypesProviders(t *testing.T) { } func TestDiscoverTypesProvisioners(t *testing.T) { - plugins, err := discoverTypesInPath("../builtin/provisioners", "ResourceProvisioner", "") + plugins, err := discoverTypesInPath("../builtin/provisioners", "terraform.ResourceProvisioner", "Provisioner") if err != nil { t.Fatalf(err.Error()) } - if !contains(plugins, "chef") { - t.Errorf("Expected to find chef provisioner") - } if !contains(plugins, "remote-exec") { t.Errorf("Expected to find remote-exec provisioner") }