From 2805a59dbd2746801d89eb5f56b12d31b86b91d3 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 11 Dec 2020 15:15:08 -0800 Subject: [PATCH] remove unused tools, add some docs --- .../acctest/provisioneracc/builders.go | 8 ++++ .../acctest/provisioneracc/core.go | 43 ------------------- .../acctest/provisioneracc/provisioners.go | 2 +- packer-plugin-sdk/acctest/testutils/utils.go | 2 +- packer-plugin-sdk/adapter/doc.go | 8 +++- 5 files changed, 17 insertions(+), 46 deletions(-) delete mode 100644 packer-plugin-sdk/acctest/provisioneracc/core.go diff --git a/packer-plugin-sdk/acctest/provisioneracc/builders.go b/packer-plugin-sdk/acctest/provisioneracc/builders.go index eb7cf5222..5540a97ae 100644 --- a/packer-plugin-sdk/acctest/provisioneracc/builders.go +++ b/packer-plugin-sdk/acctest/provisioneracc/builders.go @@ -1,3 +1,11 @@ +/* +The provisioneracc package creates a framework for provisioner acceptance +testing. + +Variables stored in this file represent implementations of the BuilderFixture +struct inside of provisioners.go +*/ + package provisioneracc import ( diff --git a/packer-plugin-sdk/acctest/provisioneracc/core.go b/packer-plugin-sdk/acctest/provisioneracc/core.go deleted file mode 100644 index 11e55b052..000000000 --- a/packer-plugin-sdk/acctest/provisioneracc/core.go +++ /dev/null @@ -1,43 +0,0 @@ -package provisioneracc - -import ( - "bytes" - "testing" - - amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs" - "github.com/hashicorp/packer/command" - "github.com/hashicorp/packer/packer" - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" - fileprovisioner "github.com/hashicorp/packer/provisioner/file" - "github.com/hashicorp/packer/provisioner/shell" -) - -// testCoreConfigBuilder creates a packer CoreConfig that has a file builder -// available. This allows us to test a builder that writes files to disk. -func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig { - components := packer.ComponentFinder{ - BuilderStore: packersdk.MapOfBuilder{ - "amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil }, - }, - ProvisionerStore: packersdk.MapOfProvisioner{ - "shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil }, - "file": func() (packersdk.Provisioner, error) { return &fileprovisioner.Provisioner{}, nil }, - }, - PostProcessorStore: packersdk.MapOfPostProcessor{}, - } - return &packer.CoreConfig{ - Components: components, - } -} - -// TestMetaFile creates a Meta object that includes a file builder -func TestMetaFile(t *testing.T) command.Meta { - var out, err bytes.Buffer - return command.Meta{ - CoreConfig: testCoreConfigBuilder(t), - Ui: &packersdk.BasicUi{ - Writer: &out, - ErrorWriter: &err, - }, - } -} diff --git a/packer-plugin-sdk/acctest/provisioneracc/provisioners.go b/packer-plugin-sdk/acctest/provisioneracc/provisioners.go index 5a6292ae4..1f3b9049c 100644 --- a/packer-plugin-sdk/acctest/provisioneracc/provisioners.go +++ b/packer-plugin-sdk/acctest/provisioneracc/provisioners.go @@ -287,7 +287,7 @@ func writeJsonTemplate(out *bytes.Buffer, filePath string, t *testing.T) { outputFile.Sync() } -// BuilderAcceptance is specialized tooling implemented by individual builders +// BuilderAcceptance is specialized tooling implemented by individual builders. // To add your builder to the provisioner testing framework, create a struct // that implements this interface, add it to the BuildersAccTest map below. // TODO add this interface to the plugin server so that Packer can request it diff --git a/packer-plugin-sdk/acctest/testutils/utils.go b/packer-plugin-sdk/acctest/testutils/utils.go index a0470a4f2..3f466df1a 100644 --- a/packer-plugin-sdk/acctest/testutils/utils.go +++ b/packer-plugin-sdk/acctest/testutils/utils.go @@ -2,7 +2,7 @@ package testutils import "os" -// CleanupFiles removes all files in the given strings. +// CleanupFiles removes all the provided filenames. func CleanupFiles(moreFiles ...string) { for _, file := range moreFiles { os.RemoveAll(file) diff --git a/packer-plugin-sdk/adapter/doc.go b/packer-plugin-sdk/adapter/doc.go index f079dc594..468d42a70 100644 --- a/packer-plugin-sdk/adapter/doc.go +++ b/packer-plugin-sdk/adapter/doc.go @@ -1,8 +1,14 @@ /* Package adapter helps command line tools connect to the guest via a Packer -communicator. A typical use is for custom provisioners that wrap command line +communicator. + +A typical use is for custom provisioners that wrap command line tools. For example, the Ansible provisioner and the Inspec provisioner both use this package to proxy communicator calls. + +You may want to use this adapter if you are writing a provisioner that wraps a +tool which under normal usage would be run locally and form a connection to the +remote instance itself. */ package adapter