diff --git a/acctest/plugin/bundled_plugin_test.go b/acctest/plugin/bundled_plugin_test.go deleted file mode 100644 index c66526109..000000000 --- a/acctest/plugin/bundled_plugin_test.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -package plugin - -import ( - _ "embed" - "errors" - "fmt" - "os" - "os/exec" - "strings" - "testing" - - "github.com/hashicorp/go-multierror" - amazonacc "github.com/hashicorp/packer-plugin-amazon/builder/ebs/acceptance" - "github.com/hashicorp/packer-plugin-sdk/acctest" - "github.com/hashicorp/packer/hcl2template/addrs" -) - -//go:embed test-fixtures/basic_amazon_bundled.pkr.hcl -var basicAmazonBundledEbsTemplate string - -func TestAccBuildBundledPlugins(t *testing.T) { - plugin := addrs.Plugin{ - Hostname: "github.com", - Namespace: "hashicorp", - Type: "amazon", - } - testCase := &acctest.PluginTestCase{ - Name: "amazon-ebs_bundled_test", - Setup: func() error { - return cleanupPluginInstallation(plugin) - }, - Teardown: func() error { - helper := amazonacc.AMIHelper{ - Region: "us-east-1", - Name: "packer-plugin-bundled-amazon-ebs-test", - } - return helper.CleanUpAmi() - }, - Template: basicAmazonBundledEbsTemplate, - Type: "amazon-ebs", - Init: false, - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - rawLogs, err := os.ReadFile(logfile) - if err != nil { - return fmt.Errorf("failed to read logs: %s", err) - } - - var errs error - - logs := string(rawLogs) - - if !strings.Contains(logs, "Warning: Bundled plugins used") { - errs = multierror.Append(errs, errors.New("expected warning about bundled plugins used, did not find it")) - } - - if !strings.Contains(logs, "Then run 'packer init' to manage installation of the plugins") { - errs = multierror.Append(errs, errors.New("expected suggestion about packer init in logs, did not find it.")) - } - - return errs - }, - } - - acctest.TestPlugin(t, testCase) -} - -//go:embed test-fixtures/basic_amazon_with_required_plugins.pkr.hcl -var basicAmazonRequiredPluginEbsTemplate string - -func TestAccBuildBundledPluginsWithRequiredPlugins(t *testing.T) { - plugin := addrs.Plugin{ - Hostname: "github.com", - Namespace: "hashicorp", - Type: "amazon", - } - testCase := &acctest.PluginTestCase{ - Name: "amazon-ebs_with_required_plugins_test", - Setup: func() error { - return cleanupPluginInstallation(plugin) - }, - Teardown: func() error { - helper := amazonacc.AMIHelper{ - Region: "us-east-1", - Name: "packer-plugin-required-plugin-amazon-ebs-test", - } - return helper.CleanUpAmi() - }, - Template: basicAmazonRequiredPluginEbsTemplate, - Type: "amazon-ebs", - Init: false, - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 1 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - rawLogs, err := os.ReadFile(logfile) - if err != nil { - return fmt.Errorf("failed to read logs: %s", err) - } - - var errs error - - logs := string(rawLogs) - - if strings.Contains(logs, "Warning: Bundled plugins used") { - errs = multierror.Append(errs, errors.New("did not expect warning about bundled plugins used")) - } - - if !strings.Contains(logs, "Missing plugins") { - errs = multierror.Append(errs, errors.New("expected error about plugins required and not installed, did not find it")) - } - - return errs - }, - } - - acctest.TestPlugin(t, testCase) -} - -//go:embed test-fixtures/basic_amazon_bundled.json -var basicAmazonBundledEbsTemplateJSON string - -func TestAccBuildBundledPluginsJSON(t *testing.T) { - plugin := addrs.Plugin{ - Hostname: "github.com", - Namespace: "hashicorp", - Type: "amazon", - } - testCase := &acctest.PluginTestCase{ - Name: "amazon-ebs_bundled_test_json", - Setup: func() error { - return cleanupPluginInstallation(plugin) - }, - Teardown: func() error { - helper := amazonacc.AMIHelper{ - Region: "us-east-1", - Name: "packer-plugin-bundled-amazon-ebs-test-json", - } - return helper.CleanUpAmi() - }, - Template: basicAmazonBundledEbsTemplateJSON, - Type: "amazon-ebs", - Init: false, - Check: func(buildCommand *exec.Cmd, logfile string) error { - if buildCommand.ProcessState != nil { - if buildCommand.ProcessState.ExitCode() != 0 { - return fmt.Errorf("Bad exit code. Logfile: %s", logfile) - } - } - - rawLogs, err := os.ReadFile(logfile) - if err != nil { - return fmt.Errorf("failed to read logs: %s", err) - } - - var errs error - - logs := string(rawLogs) - - if !strings.Contains(logs, "Warning: Bundled plugins used") { - errs = multierror.Append(errs, errors.New("expected warning about bundled plugins, did not find it.")) - } - - if !strings.Contains(logs, "plugins with the 'packer plugins install' command") { - errs = multierror.Append(errs, errors.New("expected suggestion about packer plugins install in logs, did not find it.")) - } - - return errs - }, - } - - acctest.TestPlugin(t, testCase) -} diff --git a/acctest/plugin/component_acc_test.go b/acctest/plugin/component_acc_test.go index e78c77284..53a49ad22 100644 --- a/acctest/plugin/component_acc_test.go +++ b/acctest/plugin/component_acc_test.go @@ -13,7 +13,6 @@ import ( "os/exec" "testing" - amazonacc "github.com/hashicorp/packer-plugin-amazon/builder/ebs/acceptance" "github.com/hashicorp/packer-plugin-sdk/acctest" "github.com/hashicorp/packer/hcl2template/addrs" ) @@ -32,13 +31,6 @@ func TestAccInitAndBuildBasicAmazonAmiDatasource(t *testing.T) { Setup: func() error { return cleanupPluginInstallation(plugin) }, - Teardown: func() error { - helper := amazonacc.AMIHelper{ - Region: "us-west-2", - Name: "packer-amazon-ami-test", - } - return helper.CleanUpAmi() - }, Template: basicAmazonAmiDatasourceHCL2Template, Type: "amazon-ami", Init: true, diff --git a/acctest/plugin/plugin_acc_test.go b/acctest/plugin/plugin_acc_test.go index 6549b2129..b2afe7e81 100644 --- a/acctest/plugin/plugin_acc_test.go +++ b/acctest/plugin/plugin_acc_test.go @@ -15,7 +15,6 @@ import ( "regexp" "testing" - amazonacc "github.com/hashicorp/packer-plugin-amazon/builder/ebs/acceptance" "github.com/hashicorp/packer-plugin-sdk/acctest" "github.com/hashicorp/packer-plugin-sdk/acctest/testutils" "github.com/hashicorp/packer/hcl2template/addrs" @@ -36,13 +35,6 @@ func TestAccInitAndBuildBasicAmazonEbs(t *testing.T) { Setup: func() error { return cleanupPluginInstallation(plugin) }, - Teardown: func() error { - helper := amazonacc.AMIHelper{ - Region: "us-east-1", - Name: "packer-plugin-amazon-ebs-test", - } - return helper.CleanUpAmi() - }, Template: basicAmazonEbsHCL2Template, Type: "amazon-ebs", Init: true, diff --git a/acctest/plugin/test-fixtures/basic-amazon-ami-datasource.pkr.hcl b/acctest/plugin/test-fixtures/basic-amazon-ami-datasource.pkr.hcl index 7ff2d3127..207530aa2 100644 --- a/acctest/plugin/test-fixtures/basic-amazon-ami-datasource.pkr.hcl +++ b/acctest/plugin/test-fixtures/basic-amazon-ami-datasource.pkr.hcl @@ -1,7 +1,7 @@ packer { required_plugins { amazon = { - version = ">= 0.0.1" + version = "~>1" source = "github.com/hashicorp/amazon" } } @@ -25,6 +25,7 @@ source "amazon-ebs" "basic-example" { communicator = "ssh" instance_type = "t2.micro" ssh_username = "ubuntu" + skip_create_ami = true } build { diff --git a/acctest/plugin/test-fixtures/basic-amazon-ebs.pkr.hcl b/acctest/plugin/test-fixtures/basic-amazon-ebs.pkr.hcl index aa9399a92..daaec2feb 100644 --- a/acctest/plugin/test-fixtures/basic-amazon-ebs.pkr.hcl +++ b/acctest/plugin/test-fixtures/basic-amazon-ebs.pkr.hcl @@ -1,18 +1,19 @@ packer { required_plugins { amazon = { - version = ">= 0.0.1" - source = "github.com/hashicorp/amazon" + version = "~> 1" + source = "github.com/hashicorp/amazon" } } } source "amazon-ebs" "basic-test" { - region = "us-east-1" - instance_type = "m3.medium" - source_ami = "ami-76b2a71e" - ssh_username = "ubuntu" - ami_name = "packer-plugin-amazon-ebs-test" + region = "us-east-1" + instance_type = "m3.medium" + source_ami = "ami-76b2a71e" + ssh_username = "ubuntu" + ami_name = "packer-plugin-amazon-ebs-test" + skip_create_ami = true } build { diff --git a/acctest/plugin/test-fixtures/basic_amazon_bundled.json b/acctest/plugin/test-fixtures/basic_amazon_bundled.json deleted file mode 100644 index f674cd130..000000000 --- a/acctest/plugin/test-fixtures/basic_amazon_bundled.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "builders": [{ - "type": "amazon-ebs", - "region": "us-east-1", - "instance_type": "m3.medium", - "source_ami": "ami-76b2a71e", - "ssh_username": "ubuntu", - "ami_name": "packer-plugin-bundled-amazon-ebs-test-json" - }] -} diff --git a/acctest/plugin/test-fixtures/basic_amazon_bundled.pkr.hcl b/acctest/plugin/test-fixtures/basic_amazon_bundled.pkr.hcl deleted file mode 100644 index c17a09df0..000000000 --- a/acctest/plugin/test-fixtures/basic_amazon_bundled.pkr.hcl +++ /dev/null @@ -1,11 +0,0 @@ -source "amazon-ebs" "basic-test" { - region = "us-east-1" - instance_type = "m3.medium" - source_ami = "ami-76b2a71e" - ssh_username = "ubuntu" - ami_name = "packer-plugin-bundled-amazon-ebs-test" -} - -build { - sources = ["source.amazon-ebs.basic-test"] -} diff --git a/acctest/plugin/test-fixtures/basic_amazon_with_required_plugins.pkr.hcl b/acctest/plugin/test-fixtures/basic_amazon_with_required_plugins.pkr.hcl deleted file mode 100644 index a30f85fa4..000000000 --- a/acctest/plugin/test-fixtures/basic_amazon_with_required_plugins.pkr.hcl +++ /dev/null @@ -1,20 +0,0 @@ -packer { - required_plugins { - amazon = { - source = "github.com/hashicorp/amazon", - version = "~> 1" - } - } -} - -source "amazon-ebs" "basic-test" { - region = "us-east-1" - instance_type = "m3.medium" - source_ami = "ami-76b2a71e" - ssh_username = "ubuntu" - ami_name = "packer-plugin-external-amazon-ebs-test" -} - -build { - sources = ["source.amazon-ebs.basic-test"] -} diff --git a/command/exec_test.go b/command/exec_test.go index c4bf24ab1..debb2dacb 100644 --- a/command/exec_test.go +++ b/command/exec_test.go @@ -11,7 +11,6 @@ import ( "runtime" "testing" - "github.com/hashicorp/packer-plugin-amazon/builder/ebs" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/null" @@ -121,10 +120,8 @@ func getBareComponentFinder() packer.ComponentFinder { return packer.ComponentFinder{ PluginConfig: &packer.PluginConfig{ Builders: packer.MapOfBuilder{ - "file": func() (packersdk.Builder, error) { return &file.Builder{}, nil }, - "null": func() (packersdk.Builder, error) { return &null.Builder{}, nil }, - "amazon-ebs": func() (packersdk.Builder, error) { return &ebs.Builder{}, nil }, - "azure-arm": func() (packersdk.Builder, error) { return &ebs.Builder{}, nil }, + "file": func() (packersdk.Builder, error) { return &file.Builder{}, nil }, + "null": func() (packersdk.Builder, error) { return &null.Builder{}, nil }, }, Provisioners: packer.MapOfProvisioner{ "shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },