From 307f56f560e76ba3e6452649cfb13c473102d599 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 1 Dec 2020 14:48:55 -0800 Subject: [PATCH] move postprocessor to sdk, fix generation code --- builder/vmware/iso/step_create_vmx_test.go | 2 +- command/build_test.go | 4 +-- command/exec_test.go | 4 +-- command/plugin.go | 3 +-- config.go | 20 +++++++-------- hcl2template/common_test.go | 4 +-- hcl2template/internal/mock.go | 3 +-- hcl2template/types.build.post-processor.go | 4 +-- hcl2template/types.hcl_post-processor.go | 3 +-- .../packer}/post_processor.go | 6 ++--- packer/build.go | 4 +-- packer/core.go | 8 +++--- packer/maps.go | 8 +++--- packer/plugin/client.go | 3 +-- packer/plugin/post_processor.go | 3 +-- packer/provisioner.go | 25 +++---------------- packer/provisioner_timeout.go | 2 +- packer/rpc/client.go | 2 +- packer/rpc/post_processor.go | 7 +++--- packer/rpc/post_processor_test.go | 3 +-- packer/rpc/server.go | 2 +- packer/testing.go | 4 +-- .../post-processor_test.go | 4 +-- .../docker-import/post-processor_test.go | 4 +-- .../docker-push/post-processor_test.go | 3 +-- .../docker-save/post-processor_test.go | 4 +-- .../docker-tag/post-processor_test.go | 3 +-- .../shell-local/post-processor_test.go | 6 ++--- .../vagrant-cloud/post-processor.go | 2 +- .../vagrant-cloud/post-processor_test.go | 3 +-- post-processor/vagrant/post-processor.go | 2 +- post-processor/vagrant/post-processor_test.go | 3 +-- scripts/generate-plugins.go | 2 +- .../partials/builder/hyperv/iso/Builder.mdx | 2 +- .../partials/builder/hyperv/vmcx/Builder.mdx | 2 +- .../partials/builder/vagrant/Builder.mdx | 2 +- 36 files changed, 68 insertions(+), 98 deletions(-) rename {packer => packer-plugin-sdk/packer}/post_processor.go (83%) diff --git a/builder/vmware/iso/step_create_vmx_test.go b/builder/vmware/iso/step_create_vmx_test.go index 7b3a55f88..bef646c65 100644 --- a/builder/vmware/iso/step_create_vmx_test.go +++ b/builder/vmware/iso/step_create_vmx_test.go @@ -148,7 +148,7 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner "shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil }, }, PostProcessorStore: packer.MapOfPostProcessor{ - "something": func() (packer.PostProcessor, error) { return &packer.MockPostProcessor{}, nil }, + "something": func() (packersdk.PostProcessor, error) { return &packer.MockPostProcessor{}, nil }, }, } config := packer.CoreConfig{ diff --git a/command/build_test.go b/command/build_test.go index 1605606fd..b5d9694c9 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -846,8 +846,8 @@ func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig { "file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil }, }, PostProcessorStore: packer.MapOfPostProcessor{ - "shell-local": func() (packer.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil }, - "manifest": func() (packer.PostProcessor, error) { return &manifest.PostProcessor{}, nil }, + "shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil }, + "manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil }, }, } return &packer.CoreConfig{ diff --git a/command/exec_test.go b/command/exec_test.go index a91caf7ee..8f3d2d345 100644 --- a/command/exec_test.go +++ b/command/exec_test.go @@ -129,8 +129,8 @@ func getBareComponentFinder() packer.ComponentFinder { "file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil }, }, PostProcessorStore: packer.MapOfPostProcessor{ - "shell-local": func() (packer.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil }, - "manifest": func() (packer.PostProcessor, error) { return &manifest.PostProcessor{}, nil }, + "shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil }, + "manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil }, }, } } diff --git a/command/plugin.go b/command/plugin.go index 737e27367..d557c8449 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -10,7 +10,6 @@ import ( "regexp" "strings" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer/plugin" @@ -188,7 +187,7 @@ var Provisioners = map[string]packersdk.Provisioner{ "windows-shell": new(windowsshellprovisioner.Provisioner), } -var PostProcessors = map[string]packer.PostProcessor{ +var PostProcessors = map[string]packersdk.PostProcessor{ "alicloud-import": new(alicloudimportpostprocessor.PostProcessor), "amazon-import": new(amazonimportpostprocessor.PostProcessor), "artifice": new(artificepostprocessor.PostProcessor), diff --git a/config.go b/config.go index fef54e165..75f601bb2 100644 --- a/config.go +++ b/config.go @@ -103,12 +103,12 @@ func (c *config) loadSingleComponent(path string) (string, error) { } case strings.HasPrefix(pluginName, "packer-post-processor-"): pluginName = pluginName[len("packer-post-processor-"):] - c.PostProcessors[pluginName] = func() (packer.PostProcessor, error) { + c.PostProcessors[pluginName] = func() (packersdk.PostProcessor, error) { return c.pluginClient(path).PostProcessor() } case strings.HasPrefix(pluginName, "packer-provisioner-"): pluginName = pluginName[len("packer-provisioner-"):] - c.Provisioners[pluginName] = func() (packer.Provisioner, error) { + c.Provisioners[pluginName] = func() (packersdk.Provisioner, error) { return c.pluginClient(path).Provisioner() } } @@ -194,16 +194,16 @@ func (c *config) StarHook(name string) (packersdk.Hook, error) { return c.pluginClient(name).Hook() } -// This is a proper packer.PostProcessorFunc that can be used to load -// packer.PostProcessor implementations from defined plugins. -func (c *config) StartPostProcessor(name string) (packer.PostProcessor, error) { +// This is a proper packersdk.PostProcessorFunc that can be used to load +// packersdk.PostProcessor implementations from defined plugins. +func (c *config) StartPostProcessor(name string) (packersdk.PostProcessor, error) { log.Printf("Loading post-processor: %s", name) return c.PostProcessors.Start(name) } // This is a proper packer.ProvisionerFunc that can be used to load // packer.Provisioner implementations from defined plugins. -func (c *config) StartProvisioner(name string) (packer.Provisioner, error) { +func (c *config) StartProvisioner(name string) (packersdk.Provisioner, error) { log.Printf("Loading provisioner: %s\n", name) return c.Provisioners.Start(name) } @@ -242,7 +242,7 @@ func (c *config) discoverExternalComponents(path string) error { } for pluginName, pluginPath := range pluginPaths { newPath := pluginPath // this needs to be stored in a new variable for the func below - c.PostProcessors[pluginName] = func() (packer.PostProcessor, error) { + c.PostProcessors[pluginName] = func() (packersdk.PostProcessor, error) { return c.pluginClient(newPath).PostProcessor() } externallyUsed = append(externallyUsed, pluginName) @@ -259,7 +259,7 @@ func (c *config) discoverExternalComponents(path string) error { } for pluginName, pluginPath := range pluginPaths { newPath := pluginPath // this needs to be stored in a new variable for the func below - c.Provisioners[pluginName] = func() (packer.Provisioner, error) { + c.Provisioners[pluginName] = func() (packersdk.Provisioner, error) { return c.pluginClient(newPath).Provisioner() } externallyUsed = append(externallyUsed, pluginName) @@ -333,7 +333,7 @@ func (c *config) discoverInternalComponents() error { provisioner := provisioner _, found := (c.Provisioners)[provisioner] if !found { - c.Provisioners[provisioner] = func() (packer.Provisioner, error) { + c.Provisioners[provisioner] = func() (packersdk.Provisioner, error) { bin := fmt.Sprintf("%s%splugin%spacker-provisioner-%s", packerPath, PACKERSPACE, PACKERSPACE, provisioner) return c.pluginClient(bin).Provisioner() @@ -345,7 +345,7 @@ func (c *config) discoverInternalComponents() error { postProcessor := postProcessor _, found := (c.PostProcessors)[postProcessor] if !found { - c.PostProcessors[postProcessor] = func() (packer.PostProcessor, error) { + c.PostProcessors[postProcessor] = func() (packersdk.PostProcessor, error) { bin := fmt.Sprintf("%s%splugin%spacker-post-processor-%s", packerPath, PACKERSPACE, PACKERSPACE, postProcessor) return c.pluginClient(bin).PostProcessor() diff --git a/hcl2template/common_test.go b/hcl2template/common_test.go index 6ddac96c8..b0eb30aa4 100644 --- a/hcl2template/common_test.go +++ b/hcl2template/common_test.go @@ -30,8 +30,8 @@ func getBasicParser() *Parser { "file": func() (packersdk.Provisioner, error) { return &MockProvisioner{}, nil }, }, PostProcessorsSchemas: packer.MapOfPostProcessor{ - "amazon-import": func() (packer.PostProcessor, error) { return &MockPostProcessor{}, nil }, - "manifest": func() (packer.PostProcessor, error) { return &MockPostProcessor{}, nil }, + "amazon-import": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil }, + "manifest": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil }, }, } } diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index 167154eaf..c6d7bcce8 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -7,7 +7,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/zclconf/go-cty/cty" @@ -112,7 +111,7 @@ type MockPostProcessor struct { Config MockConfig } -var _ packer.PostProcessor = new(MockPostProcessor) +var _ packersdk.PostProcessor = new(MockPostProcessor) func (b *MockPostProcessor) ConfigSpec() hcldec.ObjectSpec { return b.Config.FlatMapstructure().HCL2Spec() diff --git a/hcl2template/types.build.post-processor.go b/hcl2template/types.build.post-processor.go index fcfa2dc0e..4b91f2533 100644 --- a/hcl2template/types.build.post-processor.go +++ b/hcl2template/types.build.post-processor.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/gohcl" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // ProvisionerBlock references a detected but unparsed post processor @@ -61,7 +61,7 @@ func (p *Parser) decodePostProcessor(block *hcl.Block) (*PostProcessorBlock, hcl return postProcessor, diags } -func (cfg *PackerConfig) startPostProcessor(source SourceBlock, pp *PostProcessorBlock, ectx *hcl.EvalContext) (packer.PostProcessor, hcl.Diagnostics) { +func (cfg *PackerConfig) startPostProcessor(source SourceBlock, pp *PostProcessorBlock, ectx *hcl.EvalContext) (packersdk.PostProcessor, hcl.Diagnostics) { // ProvisionerBlock represents a detected but unparsed provisioner var diags hcl.Diagnostics diff --git a/hcl2template/types.hcl_post-processor.go b/hcl2template/types.hcl_post-processor.go index 43e35a021..ce279b72f 100644 --- a/hcl2template/types.hcl_post-processor.go +++ b/hcl2template/types.hcl_post-processor.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -16,7 +15,7 @@ import ( // calling PostProcess: with contextual variables. // This permits using "${build.ID}" values for example. type HCL2PostProcessor struct { - PostProcessor packer.PostProcessor + PostProcessor packersdk.PostProcessor postProcessorBlock *PostProcessorBlock evalContext *hcl.EvalContext builderVariables map[string]string diff --git a/packer/post_processor.go b/packer-plugin-sdk/packer/post_processor.go similarity index 83% rename from packer/post_processor.go rename to packer-plugin-sdk/packer/post_processor.go index cd47e297c..e99bcdd8a 100644 --- a/packer/post_processor.go +++ b/packer-plugin-sdk/packer/post_processor.go @@ -2,8 +2,6 @@ package packer import ( "context" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // A PostProcessor is responsible for taking an artifact of a build @@ -12,7 +10,7 @@ import ( // the result of a build, compresses it, and returns a new artifact containing // a single file of the prior artifact compressed. type PostProcessor interface { - packersdk.HCL2Speccer + HCL2Speccer // Configure is responsible for setting up configuration, storing // the state for later, and returning and errors, such as validation @@ -26,5 +24,5 @@ type PostProcessor interface { // user input for keep_input_artifact is ignored and the artifact is either // kept or discarded according to the value set in `keep`. // PostProcess is cancellable using context - PostProcess(context.Context, packersdk.Ui, packersdk.Artifact) (a packersdk.Artifact, keep bool, forceOverride bool, err error) + PostProcess(context.Context, Ui, Artifact) (a Artifact, keep bool, forceOverride bool, err error) } diff --git a/packer/build.go b/packer/build.go index 2bb39d485..d36503426 100644 --- a/packer/build.go +++ b/packer/build.go @@ -118,7 +118,7 @@ type CoreBuild struct { // CoreBuildPostProcessor Keeps track of the post-processor and the // configuration of the post-processor used within a build. type CoreBuildPostProcessor struct { - PostProcessor PostProcessor + PostProcessor packersdk.PostProcessor PType string PName string config map[string]interface{} @@ -130,7 +130,7 @@ type CoreBuildPostProcessor struct { type CoreBuildProvisioner struct { PType string PName string - Provisioner Provisioner + Provisioner packersdk.Provisioner config []interface{} } diff --git a/packer/core.go b/packer/core.go index c3f68f7c8..1c49231d5 100644 --- a/packer/core.go +++ b/packer/core.go @@ -56,10 +56,10 @@ type BuilderFunc func(name string) (packersdk.Builder, error) type HookFunc func(name string) (packersdk.Hook, error) // The function type used to lookup PostProcessor implementations. -type PostProcessorFunc func(name string) (PostProcessor, error) +type PostProcessorFunc func(name string) (packersdk.PostProcessor, error) // The function type used to lookup Provisioner implementations. -type ProvisionerFunc func(name string) (Provisioner, error) +type ProvisionerFunc func(name string) (packersdk.Provisioner, error) type BasicStore interface { Has(name string) bool @@ -73,12 +73,12 @@ type BuilderStore interface { type ProvisionerStore interface { BasicStore - Start(name string) (Provisioner, error) + Start(name string) (packersdk.Provisioner, error) } type PostProcessorStore interface { BasicStore - Start(name string) (PostProcessor, error) + Start(name string) (packersdk.PostProcessor, error) } // ComponentFinder is a struct that contains the various function diff --git a/packer/maps.go b/packer/maps.go index 1f30d991c..388aa2381 100644 --- a/packer/maps.go +++ b/packer/maps.go @@ -6,14 +6,14 @@ import ( packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -type MapOfProvisioner map[string]func() (Provisioner, error) +type MapOfProvisioner map[string]func() (packersdk.Provisioner, error) func (mop MapOfProvisioner) Has(provisioner string) bool { _, res := mop[provisioner] return res } -func (mop MapOfProvisioner) Start(provisioner string) (Provisioner, error) { +func (mop MapOfProvisioner) Start(provisioner string) (packersdk.Provisioner, error) { p, found := mop[provisioner] if !found { return nil, fmt.Errorf("Unknown provisioner %s", provisioner) @@ -29,14 +29,14 @@ func (mop MapOfProvisioner) List() []string { return res } -type MapOfPostProcessor map[string]func() (PostProcessor, error) +type MapOfPostProcessor map[string]func() (packersdk.PostProcessor, error) func (mopp MapOfPostProcessor) Has(postProcessor string) bool { _, res := mopp[postProcessor] return res } -func (mopp MapOfPostProcessor) Start(postProcessor string) (PostProcessor, error) { +func (mopp MapOfPostProcessor) Start(postProcessor string) (packersdk.PostProcessor, error) { p, found := mopp[postProcessor] if !found { return nil, fmt.Errorf("Unknown post-processor %s", postProcessor) diff --git a/packer/plugin/client.go b/packer/plugin/client.go index c6564ad45..ce450ba17 100644 --- a/packer/plugin/client.go +++ b/packer/plugin/client.go @@ -16,7 +16,6 @@ import ( "time" "unicode" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" packrpc "github.com/hashicorp/packer/packer/rpc" ) @@ -153,7 +152,7 @@ func (c *Client) Hook() (packersdk.Hook, error) { // Returns a post-processor implementation that is communicating over // this client. If the client hasn't been started, this will start it. -func (c *Client) PostProcessor() (packer.PostProcessor, error) { +func (c *Client) PostProcessor() (packersdk.PostProcessor, error) { client, err := c.packrpcClient() if err != nil { return nil, err diff --git a/packer/plugin/post_processor.go b/packer/plugin/post_processor.go index fa98ebaf0..68706863e 100644 --- a/packer/plugin/post_processor.go +++ b/packer/plugin/post_processor.go @@ -5,12 +5,11 @@ import ( "log" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdPostProcessor struct { - p packer.PostProcessor + p packersdk.PostProcessor client *Client } diff --git a/packer/provisioner.go b/packer/provisioner.go index b1ac9c005..3a7449027 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -12,26 +12,9 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata" ) -// A provisioner is responsible for installing and configuring software -// on a machine prior to building the actual image. -type Provisioner interface { - packersdk.HCL2Speccer - - // Prepare is called with a set of configurations to setup the - // internal state of the provisioner. The multiple configurations - // should be merged in some sane way. - Prepare(...interface{}) error - - // Provision is called to actually provision the machine. A context is - // given for cancellation, a UI is given to communicate with the user, and - // a communicator is given that is guaranteed to be connected to some - // machine so that provisioning can be done. - Provision(context.Context, packersdk.Ui, packersdk.Communicator, map[string]interface{}) error -} - // A HookedProvisioner represents a provisioner and information describing it type HookedProvisioner struct { - Provisioner Provisioner + Provisioner packersdk.Provisioner Config interface{} TypeName string } @@ -151,7 +134,7 @@ func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, c // the provisioner is actually run. type PausedProvisioner struct { PauseBefore time.Duration - Provisioner Provisioner + Provisioner packersdk.Provisioner } func (p *PausedProvisioner) ConfigSpec() hcldec.ObjectSpec { return p.ConfigSpec() } @@ -177,7 +160,7 @@ func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm // the provisioner whenever there's an error. type RetriedProvisioner struct { MaxRetries int - Provisioner Provisioner + Provisioner packersdk.Provisioner } func (r *RetriedProvisioner) ConfigSpec() hcldec.ObjectSpec { return r.ConfigSpec() } @@ -218,7 +201,7 @@ func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, com // DebuggedProvisioner is a Provisioner implementation that waits until a key // press before the provisioner is actually run. type DebuggedProvisioner struct { - Provisioner Provisioner + Provisioner packersdk.Provisioner cancelCh chan struct{} doneCh chan struct{} diff --git a/packer/provisioner_timeout.go b/packer/provisioner_timeout.go index 6b2b5649c..57e96ada7 100644 --- a/packer/provisioner_timeout.go +++ b/packer/provisioner_timeout.go @@ -11,7 +11,7 @@ import ( // TimeoutProvisioner is a Provisioner implementation that can timeout after a // duration type TimeoutProvisioner struct { - Provisioner + packersdk.Provisioner Timeout time.Duration } diff --git a/packer/rpc/client.go b/packer/rpc/client.go index 49752a384..b84b8b600 100644 --- a/packer/rpc/client.go +++ b/packer/rpc/client.go @@ -119,7 +119,7 @@ func (c *Client) Hook() packersdk.Hook { } } -func (c *Client) PostProcessor() packer.PostProcessor { +func (c *Client) PostProcessor() packersdk.PostProcessor { return &postProcessor{ commonClient: commonClient{ endpoint: DefaultPostProcessorEndpoint, diff --git a/packer/rpc/post_processor.go b/packer/rpc/post_processor.go index 92818b730..0595c4bfe 100644 --- a/packer/rpc/post_processor.go +++ b/packer/rpc/post_processor.go @@ -4,24 +4,23 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.PostProcessor where the PostProcessor is actually +// An implementation of packersdk.PostProcessor where the PostProcessor is actually // executed over an RPC connection. type postProcessor struct { commonClient } -// PostProcessorServer wraps a packer.PostProcessor implementation and makes it +// PostProcessorServer wraps a packersdk.PostProcessor implementation and makes it // exportable as part of a Golang RPC server. type PostProcessorServer struct { context context.Context contextCancel func() commonServer - p packer.PostProcessor + p packersdk.PostProcessor } type PostProcessorConfigureArgs struct { diff --git a/packer/rpc/post_processor_test.go b/packer/rpc/post_processor_test.go index 25507bfa5..4ccfd7167 100644 --- a/packer/rpc/post_processor_test.go +++ b/packer/rpc/post_processor_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -134,7 +133,7 @@ func TestPostProcessorRPC_cancel(t *testing.T) { func TestPostProcessor_Implements(t *testing.T) { var raw interface{} raw = new(postProcessor) - if _, ok := raw.(packer.PostProcessor); !ok { + if _, ok := raw.(packersdk.PostProcessor); !ok { t.Fatal("not a postprocessor") } } diff --git a/packer/rpc/server.go b/packer/rpc/server.go index 0cc7bd43e..dc648f427 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -103,7 +103,7 @@ func (s *Server) RegisterHook(h packersdk.Hook) error { }) } -func (s *Server) RegisterPostProcessor(p packer.PostProcessor) error { +func (s *Server) RegisterPostProcessor(p packersdk.PostProcessor) error { return s.server.RegisterName(DefaultPostProcessorEndpoint, &PostProcessorServer{ commonServer: commonServer{ selfConfigurable: p, diff --git a/packer/testing.go b/packer/testing.go index 8ced163bf..b6162093a 100644 --- a/packer/testing.go +++ b/packer/testing.go @@ -58,7 +58,7 @@ func TestProvisioner(t *testing.T, c *CoreConfig, n string) *MockProvisioner { var b MockProvisioner c.Components.ProvisionerStore = MapOfProvisioner{ - n: func() (Provisioner, error) { return &b, nil }, + n: func() (packersdk.Provisioner, error) { return &b, nil }, } return &b @@ -70,7 +70,7 @@ func TestPostProcessor(t *testing.T, c *CoreConfig, n string) *MockPostProcessor var b MockPostProcessor c.Components.PostProcessorStore = MapOfPostProcessor{ - n: func() (PostProcessor, error) { return &b, nil }, + n: func() (packersdk.PostProcessor, error) { return &b, nil }, } return &b diff --git a/post-processor/digitalocean-import/post-processor_test.go b/post-processor/digitalocean-import/post-processor_test.go index 2f89d7e0f..23f664d90 100644 --- a/post-processor/digitalocean-import/post-processor_test.go +++ b/post-processor/digitalocean-import/post-processor_test.go @@ -3,11 +3,11 @@ package digitaloceanimport import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func TestPostProcessor_ImageArtifactExtraction(t *testing.T) { diff --git a/post-processor/docker-import/post-processor_test.go b/post-processor/docker-import/post-processor_test.go index 1b28ad1f3..601788af5 100644 --- a/post-processor/docker-import/post-processor_test.go +++ b/post-processor/docker-import/post-processor_test.go @@ -3,9 +3,9 @@ package dockerimport import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } diff --git a/post-processor/docker-push/post-processor_test.go b/post-processor/docker-push/post-processor_test.go index ba9d84d93..94c6e03b8 100644 --- a/post-processor/docker-push/post-processor_test.go +++ b/post-processor/docker-push/post-processor_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" ) @@ -19,7 +18,7 @@ func testUi() *packersdk.BasicUi { } func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func TestPostProcessor_PostProcess(t *testing.T) { diff --git a/post-processor/docker-save/post-processor_test.go b/post-processor/docker-save/post-processor_test.go index 02bdaec18..206102502 100644 --- a/post-processor/docker-save/post-processor_test.go +++ b/post-processor/docker-save/post-processor_test.go @@ -3,9 +3,9 @@ package dockersave import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } diff --git a/post-processor/docker-tag/post-processor_test.go b/post-processor/docker-tag/post-processor_test.go index 2d6fc0562..df3e2baca 100644 --- a/post-processor/docker-tag/post-processor_test.go +++ b/post-processor/docker-tag/post-processor_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" dockerimport "github.com/hashicorp/packer/post-processor/docker-import" "github.com/stretchr/testify/assert" @@ -36,7 +35,7 @@ func testUi() *packersdk.BasicUi { } func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func TestPostProcessor_PostProcess(t *testing.T) { diff --git a/post-processor/shell-local/post-processor_test.go b/post-processor/shell-local/post-processor_test.go index 515704f9d..fe4e67063 100644 --- a/post-processor/shell-local/post-processor_test.go +++ b/post-processor/shell-local/post-processor_test.go @@ -6,12 +6,12 @@ import ( "runtime" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func testConfig() map[string]interface{} { @@ -23,7 +23,7 @@ func testConfig() map[string]interface{} { func TestPostProcessor_Impl(t *testing.T) { var raw interface{} raw = &PostProcessor{} - if _, ok := raw.(packer.PostProcessor); !ok { + if _, ok := raw.(packersdk.PostProcessor); !ok { t.Fatalf("must be a post processor") } } diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 4b87f0c4b..32b4e4fc1 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -1,6 +1,6 @@ //go:generate mapstructure-to-hcl2 -type Config -// vagrant_cloud implements the packer.PostProcessor interface and adds a +// vagrant_cloud implements the packersdk.PostProcessor interface and adds a // post-processor that uploads artifacts from the vagrant post-processor // and vagrant builder to Vagrant Cloud (vagrantcloud.com) or manages // self hosted boxes on the Vagrant Cloud diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index 56e2b8006..0ff209a1d 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -13,7 +13,6 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/stretchr/testify/assert" ) @@ -425,7 +424,7 @@ func testUi() *packersdk.BasicUi { } func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func TestProviderFromBuilderName(t *testing.T) { diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index e73739989..341aef2d6 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -1,6 +1,6 @@ //go:generate mapstructure-to-hcl2 -type Config -// vagrant implements the packer.PostProcessor interface and adds a +// vagrant implements the packersdk.PostProcessor interface and adds a // post-processor that turns artifacts of known builders into Vagrant // boxes. package vagrant diff --git a/post-processor/vagrant/post-processor_test.go b/post-processor/vagrant/post-processor_test.go index 3be292f99..d2b947925 100644 --- a/post-processor/vagrant/post-processor_test.go +++ b/post-processor/vagrant/post-processor_test.go @@ -9,7 +9,6 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -34,7 +33,7 @@ func testUi() *packersdk.BasicUi { } func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packer.PostProcessor = new(PostProcessor) + var _ packersdk.PostProcessor = new(PostProcessor) } func TestPostProcessorPrepare_compressionLevel(t *testing.T) { diff --git a/scripts/generate-plugins.go b/scripts/generate-plugins.go index e6a53f5c5..5034aab60 100644 --- a/scripts/generate-plugins.go +++ b/scripts/generate-plugins.go @@ -97,7 +97,7 @@ type plugin struct { func makeMap(varName, varType string, items []plugin) string { output := "" - output += fmt.Sprintf("var %s = map[string]packer.%s{\n", varName, varType) + output += fmt.Sprintf("var %s = map[string]packersdk.%s{\n", varName, varType) for _, item := range items { output += fmt.Sprintf("\t\"%s\": new(%s.%s),\n", item.PluginName, item.ImportName, item.TypeName) } diff --git a/website/pages/partials/builder/hyperv/iso/Builder.mdx b/website/pages/partials/builder/hyperv/iso/Builder.mdx index 882c75759..d1741938a 100644 --- a/website/pages/partials/builder/hyperv/iso/Builder.mdx +++ b/website/pages/partials/builder/hyperv/iso/Builder.mdx @@ -1,4 +1,4 @@ -Builder implements packer.Builder and builds the actual Hyperv +Builder implements packersdk.Builder and builds the actual Hyperv images. diff --git a/website/pages/partials/builder/hyperv/vmcx/Builder.mdx b/website/pages/partials/builder/hyperv/vmcx/Builder.mdx index 339182ec8..e32f49ca6 100644 --- a/website/pages/partials/builder/hyperv/vmcx/Builder.mdx +++ b/website/pages/partials/builder/hyperv/vmcx/Builder.mdx @@ -1,4 +1,4 @@ -Builder implements packer.Builder and builds the actual Hyperv +Builder implements packersdk.Builder and builds the actual Hyperv images. diff --git a/website/pages/partials/builder/vagrant/Builder.mdx b/website/pages/partials/builder/vagrant/Builder.mdx index e14895d17..e23466d3c 100644 --- a/website/pages/partials/builder/vagrant/Builder.mdx +++ b/website/pages/partials/builder/vagrant/Builder.mdx @@ -1,4 +1,4 @@ -Builder implements packer.Builder and builds the actual VirtualBox +Builder implements packersdk.Builder and builds the actual VirtualBox images.