extract builder interface to sdk

This commit is contained in:
Megan Marsh 2020-12-01 13:42:11 -08:00
parent 89199a4c57
commit faa3832537
85 changed files with 142 additions and 142 deletions

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config,AlicloudDiskDevice
// The alicloud contains a packer.Builder implementation that
// The alicloud contains a packersdk.Builder implementation that
// builds ecs images for alicloud.
package ecs

View File

@ -4,7 +4,7 @@ import (
"reflect"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
helperconfig "github.com/hashicorp/packer/packer-plugin-sdk/template/config"
)
@ -24,7 +24,7 @@ func testBuilderConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -3,7 +3,7 @@ package chroot
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -19,7 +19,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -12,6 +12,7 @@ import (
amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
testshelper "github.com/hashicorp/packer/helper/tests"
)
@ -56,6 +57,6 @@ func (s *AmazonEBSAccTest) CleanUp() error {
func (s *AmazonEBSAccTest) GetBuilderStore() packer.MapOfBuilder {
return packer.MapOfBuilder{
"amazon-ebs": func() (packer.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
}
}

View File

@ -1,7 +1,7 @@
//go:generate struct-markdown
//go:generate mapstructure-to-hcl2 -type Config
// The amazonebs package contains a packer.Builder implementation that
// The amazonebs package contains a packersdk.Builder implementation that
// builds AMIs for Amazon EC2.
//
// In general, there are two types of AMIs that can be created: ebs-backed or

View File

@ -3,7 +3,7 @@ package ebs
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -21,7 +21,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,7 +1,7 @@
//go:generate struct-markdown
//go:generate mapstructure-to-hcl2 -type Config,RootBlockDevice,BlockDevice
// The ebssurrogate package contains a packer.Builder implementation that
// The ebssurrogate package contains a packersdk.Builder implementation that
// builds a new EBS-backed AMI using an ephemeral instance.
package ebssurrogate

View File

@ -5,7 +5,7 @@ import (
"github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -22,7 +22,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatal("Builder should be a builder")
}
}

View File

@ -1,7 +1,7 @@
//go:generate struct-markdown
//go:generate mapstructure-to-hcl2 -type Config,BlockDevice
// The ebsvolume package contains a packer.Builder implementation that builds
// The ebsvolume package contains a packersdk.Builder implementation that builds
// EBS volumes for Amazon EC2 using an ephemeral instance,
package ebsvolume

View File

@ -3,7 +3,7 @@ package ebsvolume
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -20,7 +20,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,7 +1,7 @@
//go:generate struct-markdown
//go:generate mapstructure-to-hcl2 -type Config
// The instance package contains a packer.Builder implementation that builds
// The instance package contains a packersdk.Builder implementation that builds
// AMIs for Amazon EC2 backed by instance storage, as opposed to EBS storage.
package instance

View File

@ -5,7 +5,7 @@ import (
"os"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() (config map[string]interface{}, tf *os.File) {
@ -33,7 +33,7 @@ func testConfig() (config map[string]interface{}, tf *os.File) {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -18,7 +18,6 @@ import (
"github.com/hashicorp/hcl/v2/hcldec"
azcommon "github.com/hashicorp/packer/builder/azure/common"
"github.com/hashicorp/packer/builder/azure/common/client"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/chroot"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
@ -146,7 +145,7 @@ type Builder struct {
}
// verify interface implementation
var _ packer.Builder = &Builder{}
var _ packersdk.Builder = &Builder{}
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }

View File

@ -32,7 +32,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, nil
}
// Run implements the packer.Builder interface.
// Run implements the packersdk.Builder interface.
func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) {
b.ui = ui

View File

@ -3,14 +3,14 @@ package cloudstack
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_Impl(t *testing.T) {
var raw interface{} = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
t.Fatalf("Builder does not implement packer.Builder")
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder does not implement packersdk.Builder")
}
}

View File

@ -1,4 +1,4 @@
// The digitalocean package contains a packer.Builder implementation
// The digitalocean package contains a packersdk.Builder implementation
// that builds DigitalOcean images (snapshots).
package digitalocean

View File

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -21,7 +21,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -3,9 +3,9 @@ package docker
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_implBuilder(t *testing.T) {
var _ packer.Builder = new(Builder)
var _ packersdk.Builder = new(Builder)
}

View File

@ -6,12 +6,11 @@ import (
"testing"
builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_implBuilder(t *testing.T) {
var _ packer.Builder = new(Builder)
var _ packersdk.Builder = new(Builder)
}
func TestBuilderFileAcc_content(t *testing.T) {

View File

@ -1,4 +1,4 @@
// The googlecompute package contains a packer.Builder implementation that
// The googlecompute package contains a packersdk.Builder implementation that
// builds images for Google Compute Engine.
package googlecompute

View File

@ -45,7 +45,7 @@ const (
DefaultPassword = ""
)
// Builder implements packer.Builder and builds the actual Hyperv
// Builder implements packersdk.Builder and builds the actual Hyperv
// images.
type Builder struct {
config Config

View File

@ -33,7 +33,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -36,7 +36,7 @@ const (
DefaultPassword = ""
)
// Builder implements packer.Builder and builds the actual Hyperv
// Builder implements packersdk.Builder and builds the actual Hyperv
// images.
type Builder struct {
config Config

View File

@ -32,7 +32,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -1,4 +1,4 @@
// The linode package contains a packer.Builder implementation
// The linode package contains a packersdk.Builder implementation
// that builds Linode images.
package linode

View File

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -21,7 +21,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -4,7 +4,7 @@ import (
"os"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -50,7 +50,7 @@ func TestBuilderPrepare_ConfigFile(t *testing.T) {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -4,7 +4,7 @@ import (
"os"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -71,7 +71,7 @@ func TestBuilderPrepare_ConfigFile(t *testing.T) {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -11,7 +11,7 @@ import (
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Builder assume this implements packer.Builder
// Builder assume this implements packersdk.Builder
type Builder struct {
config Config
stateBag multistep.StateBag

View File

@ -3,9 +3,9 @@ package null
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_implBuilder(t *testing.T) {
var _ packer.Builder = new(Builder)
var _ packersdk.Builder = new(Builder)
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -19,7 +19,7 @@ func testConfig() map[string]interface{} {
func TestImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config,ImageFilter,ImageFilterOptions
// The openstack package contains a packer.Builder implementation that
// The openstack package contains a packersdk.Builder implementation that
// builds Images for openstack.
package openstack

View File

@ -3,13 +3,13 @@ package openstack
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,4 +1,4 @@
// Package oci contains a packer.Builder implementation that builds Oracle
// Package oci contains a packersdk.Builder implementation that builds Oracle
// Bare Metal Cloud Services (OCI) images.
package oci

View File

@ -3,13 +3,13 @@ package oci
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config
// Package bsu contains a packer.Builder implementation that
// Package bsu contains a packersdk.Builder implementation that
// builds OMIs for Outscale OAPI.
//
// In general, there are two types of OMIs that can be created: ebs-backed or

View File

@ -3,7 +3,7 @@ package bsu
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -21,7 +21,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config,RootBlockDevice
// Package bsusurrogate contains a packer.Builder implementation that
// Package bsusurrogate contains a packersdk.Builder implementation that
// builds a new EBS-backed OMI using an ephemeral instance.
package bsusurrogate

View File

@ -3,13 +3,13 @@ package bsusurrogate
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatal("Builder should be a builder")
}
}

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config,BlockDevice
// The ebsvolume package contains a packer.Builder implementation that
// The ebsvolume package contains a packersdk.Builder implementation that
// builds EBS volumes for Outscale using an ephemeral instance,
package bsuvolume

View File

@ -3,7 +3,7 @@ package bsuvolume
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -20,7 +20,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -24,7 +24,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -13,7 +13,7 @@ import (
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Builder implements packer.Builder and builds the actual Parallels
// Builder implements packersdk.Builder and builds the actual Parallels
// images.
type Builder struct {
config Config

View File

@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -20,7 +20,7 @@ func testConfig() map[string]interface{} {
func TestImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -4,7 +4,6 @@ import (
proxmoxapi "github.com/Telmate/proxmox-api-go/proxmox"
"github.com/hashicorp/hcl/v2/hcldec"
proxmox "github.com/hashicorp/packer/builder/proxmox/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
@ -19,8 +18,8 @@ type Builder struct {
config Config
}
// Builder implements packer.Builder
var _ packer.Builder = &Builder{}
// Builder implements packersdk.Builder
var _ packersdk.Builder = &Builder{}
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }

View File

@ -6,7 +6,6 @@ import (
proxmoxapi "github.com/Telmate/proxmox-api-go/proxmox"
"github.com/hashicorp/hcl/v2/hcldec"
proxmox "github.com/hashicorp/packer/builder/proxmox/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
@ -19,8 +18,8 @@ type Builder struct {
config Config
}
// Builder implements packer.Builder
var _ packer.Builder = &Builder{}
// Builder implements packersdk.Builder
var _ packersdk.Builder = &Builder{}
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }

View File

@ -3,13 +3,13 @@ package qemu
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -1,4 +1,4 @@
// The scaleway package contains a packer.Builder implementation
// The scaleway package contains a packersdk.Builder implementation
// that builds Scaleway images (snapshots).
package scaleway

View File

@ -4,7 +4,7 @@ import (
"strconv"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -22,7 +22,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -1,6 +1,6 @@
//go:generate mapstructure-to-hcl2 -type Config
// The ucloud-uhost contains a packer.Builder implementation that
// The ucloud-uhost contains a packersdk.Builder implementation that
// builds uhost images for UCloud UHost instance.
package uhost

View File

@ -5,7 +5,7 @@ import (
"testing"
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testBuilderConfig() map[string]interface{} {
@ -25,7 +25,7 @@ func testBuilderConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -24,7 +24,7 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
// Builder implements packer.Builder and builds the actual VirtualBox
// Builder implements packersdk.Builder and builds the actual VirtualBox
// images.
type Builder struct {
config Config

View File

@ -3,13 +3,13 @@ package vagrant
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/packer/builder/virtualbox/iso"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
testshelper "github.com/hashicorp/packer/helper/tests"
)
@ -41,6 +42,6 @@ func (v *VirtualBoxISOAccTest) CleanUp() error {
func (v *VirtualBoxISOAccTest) GetBuilderStore() packer.MapOfBuilder {
return packer.MapOfBuilder{
"virtualbox-iso": func() (packer.Builder, error) { return &iso.Builder{}, nil },
"virtualbox-iso": func() (packersdk.Builder, error) { return &iso.Builder{}, nil },
}
}

View File

@ -24,7 +24,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -13,7 +13,7 @@ import (
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Builder implements packer.Builder and builds the actual VirtualBox
// Builder implements packersdk.Builder and builds the actual VirtualBox
// images.
type Builder struct {
config Config

View File

@ -13,7 +13,7 @@ import (
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Builder implements packer.Builder and builds the actual VirtualBox
// Builder implements packersdk.Builder and builds the actual VirtualBox
// images.
type Builder struct {
config Config

View File

@ -25,7 +25,7 @@ func testConfig() map[string]interface{} {
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Error("Builder must implement builder.")
}
}

View File

@ -139,7 +139,7 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner
// create our config to test the vmware-iso builder
components := packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"vmware-iso": func() (packer.Builder, error) { return &Builder{}, nil },
"vmware-iso": func() (packersdk.Builder, error) { return &Builder{}, nil },
},
Hook: func(n string) (packersdk.Hook, error) {
return &packersdk.DispatchHook{}, nil

View File

@ -15,7 +15,7 @@ import (
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Builder implements packer.Builder and builds the actual VMware
// Builder implements packersdk.Builder and builds the actual VMware
// images.
type Builder struct {
config Config

View File

@ -3,13 +3,13 @@ package clone
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestCloneBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -3,12 +3,12 @@ package yandex
import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{} = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
if _, ok := raw.(packersdk.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}

View File

@ -69,9 +69,9 @@ func testMetaParallel(t *testing.T, builder *ParallelTestBuilder, locked *Locked
CoreConfig: &packer.CoreConfig{
Components: packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"parallel-test": func() (packer.Builder, error) { return builder, nil },
"file": func() (packer.Builder, error) { return &file.Builder{}, nil },
"lock": func() (packer.Builder, error) { return locked, nil },
"parallel-test": func() (packersdk.Builder, error) { return builder, nil },
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
"lock": func() (packersdk.Builder, error) { return locked, nil },
},
ProvisionerStore: packer.MapOfProvisioner{
"sleep": func() (packer.Provisioner, error) { return &sleep.Provisioner{}, nil },

View File

@ -837,8 +837,8 @@ func fileExists(filename string) bool {
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
components := packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"file": func() (packer.Builder, error) { return &file.Builder{}, nil },
"null": func() (packer.Builder, error) { return &null.Builder{}, nil },
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
},
ProvisionerStore: packer.MapOfProvisioner{
"shell-local": func() (packer.Provisioner, error) { return &shell_local.Provisioner{}, nil },

View File

@ -17,7 +17,7 @@ import (
func testCoreConfigSleepBuilder(t *testing.T) *packer.CoreConfig {
components := packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"file": func() (packer.Builder, error) { return &file.Builder{}, nil },
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
},
ProvisionerStore: packer.MapOfProvisioner{
"sleep": func() (packer.Provisioner, error) { return &sleep.Provisioner{}, nil },

View File

@ -119,9 +119,9 @@ func commandMeta() Meta {
func getBareComponentFinder() packer.ComponentFinder {
return packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"file": func() (packer.Builder, error) { return &file.Builder{}, nil },
"null": func() (packer.Builder, error) { return &null.Builder{}, nil },
"amazon-ebs": func() (packer.Builder, error) { return &ebs.Builder{}, nil },
"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 },
},
ProvisionerStore: packer.MapOfProvisioner{
"shell-local": func() (packer.Provisioner, error) { return &shell_local.Provisioner{}, nil },

View File

@ -11,6 +11,7 @@ import (
"strings"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer/plugin"
alicloudecsbuilder "github.com/hashicorp/packer/builder/alicloud/ecs"
@ -111,7 +112,7 @@ type PluginCommand struct {
Meta
}
var Builders = map[string]packer.Builder{
var Builders = map[string]packersdk.Builder{
"alicloud-ecs": new(alicloudecsbuilder.Builder),
"amazon-chroot": new(amazonchrootbuilder.Builder),
"amazon-ebs": new(amazonebsbuilder.Builder),

View File

@ -98,7 +98,7 @@ func (c *config) loadSingleComponent(path string) (string, error) {
switch {
case strings.HasPrefix(pluginName, "packer-builder-"):
pluginName = pluginName[len("packer-builder-"):]
c.Builders[pluginName] = func() (packer.Builder, error) {
c.Builders[pluginName] = func() (packersdk.Builder, error) {
return c.pluginClient(path).Builder()
}
case strings.HasPrefix(pluginName, "packer-post-processor-"):
@ -180,9 +180,9 @@ func (c *config) Discover() error {
return nil
}
// This is a proper packer.BuilderFunc that can be used to load packer.Builder
// This is a proper packer.BuilderFunc that can be used to load packersdk.Builder
// implementations from the defined plugins.
func (c *config) StartBuilder(name string) (packer.Builder, error) {
func (c *config) StartBuilder(name string) (packersdk.Builder, error) {
log.Printf("Loading builder: %s\n", name)
return c.Builders.Start(name)
}
@ -225,7 +225,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.Builders[pluginName] = func() (packer.Builder, error) {
c.Builders[pluginName] = func() (packersdk.Builder, error) {
return c.pluginClient(newPath).Builder()
}
externallyUsed = append(externallyUsed, pluginName)
@ -321,7 +321,7 @@ func (c *config) discoverInternalComponents() error {
builder := builder
_, found := (c.Builders)[builder]
if !found {
c.Builders[builder] = func() (packer.Builder, error) {
c.Builders[builder] = func() (packersdk.Builder, error) {
bin := fmt.Sprintf("%s%splugin%spacker-builder-%s",
packerPath, PACKERSPACE, PACKERSPACE, builder)
return c.pluginClient(bin).Builder()

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/packer/builder/null"
. "github.com/hashicorp/packer/hcl2template/internal"
"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"
)
@ -20,9 +21,9 @@ func getBasicParser() *Parser {
return &Parser{
Parser: hclparse.NewParser(),
BuilderSchemas: packer.MapOfBuilder{
"amazon-ebs": func() (packer.Builder, error) { return &MockBuilder{}, nil },
"virtualbox-iso": func() (packer.Builder, error) { return &MockBuilder{}, nil },
"null": func() (packer.Builder, error) { return &null.Builder{}, nil },
"amazon-ebs": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
"virtualbox-iso": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
},
ProvisionersSchemas: packer.MapOfProvisioner{
"shell": func() (packer.Provisioner, error) { return &MockProvisioner{}, nil },

View File

@ -70,7 +70,7 @@ type MockBuilder struct {
Config MockConfig
}
var _ packer.Builder = new(MockBuilder)
var _ packersdk.Builder = new(MockBuilder)
func (b *MockBuilder) ConfigSpec() hcldec.ObjectSpec { return b.Config.FlatMapstructure().HCL2Spec() }

View File

@ -7,6 +7,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"
"github.com/zclconf/go-cty/cty"
)
@ -88,7 +89,7 @@ func (p *Parser) decodeSource(block *hcl.Block) (SourceBlock, hcl.Diagnostics) {
return source, diags
}
func (cfg *PackerConfig) startBuilder(source SourceBlock, ectx *hcl.EvalContext, opts packer.GetBuildsOptions) (packer.Builder, hcl.Diagnostics, []string) {
func (cfg *PackerConfig) startBuilder(source SourceBlock, ectx *hcl.EvalContext, opts packer.GetBuildsOptions) (packersdk.Builder, hcl.Diagnostics, []string) {
var diags hcl.Diagnostics
builder, err := cfg.builderSchemas.Start(source.Type)

View File

@ -28,7 +28,7 @@ type TestCase struct {
// Builder is the Builder that will be tested. It will be available
// as the "test" builder in the template.
Builder packer.Builder
Builder packersdk.Builder
// Template is the template contents to use.
Template string
@ -66,10 +66,10 @@ type TestT interface {
type TestBuilderStore struct {
packer.BuilderStore
StartFn func(name string) (packer.Builder, error)
StartFn func(name string) (packersdk.Builder, error)
}
func (tbs TestBuilderStore) Start(name string) (packer.Builder, error) { return tbs.StartFn(name) }
func (tbs TestBuilderStore) Start(name string) (packersdk.Builder, error) { return tbs.StartFn(name) }
// Test performs an acceptance test on a backend with the given test case.
//
@ -115,7 +115,7 @@ func Test(t TestT, c TestCase) {
core := packer.NewCore(&packer.CoreConfig{
Components: packer.ComponentFinder{
BuilderStore: TestBuilderStore{
StartFn: func(n string) (packer.Builder, error) {
StartFn: func(n string) (packersdk.Builder, error) {
if n == "test" {
return c.Builder, nil
}

View File

@ -26,7 +26,7 @@ func FileExists(filename string) bool {
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
components := packer.ComponentFinder{
BuilderStore: packer.MapOfBuilder{
"amazon-ebs": func() (packer.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
},
ProvisionerStore: packer.MapOfProvisioner{
"shell": func() (packer.Provisioner, error) { return &shell.Provisioner{}, nil },

View File

@ -2,8 +2,6 @@ package packer
import (
"context"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Implementers of Builder are responsible for actually building images
@ -17,7 +15,7 @@ import (
// parallelism is strictly disabled, so it is safe to request input from
// stdin and so on.
type Builder interface {
packersdk.HCL2Speccer
HCL2Speccer
// Prepare is responsible for configuring the builder and validating
// that configuration. Any setup should be done in this method. Note that
@ -37,5 +35,5 @@ type Builder interface {
Prepare(...interface{}) ([]string, []string, error)
// Run is where the actual build should take place. It takes a Build and a Ui.
Run(context.Context, packersdk.Ui, packersdk.Hook) (packersdk.Artifact, error)
Run(context.Context, Ui, Hook) (Artifact, error)
}

View File

@ -95,7 +95,7 @@ type Build interface {
type CoreBuild struct {
BuildName string
Type string
Builder Builder
Builder packersdk.Builder
BuilderConfig interface{}
BuilderType string
hooks map[string][]packersdk.Hook

View File

@ -50,7 +50,7 @@ type CoreConfig struct {
}
// The function type used to lookup Builder implementations.
type BuilderFunc func(name string) (Builder, error)
type BuilderFunc func(name string) (packersdk.Builder, error)
// The function type used to lookup Hook implementations.
type HookFunc func(name string) (packersdk.Hook, error)
@ -68,7 +68,7 @@ type BasicStore interface {
type BuilderStore interface {
BasicStore
Start(name string) (Builder, error)
Start(name string) (packersdk.Builder, error)
}
type ProvisionerStore interface {

View File

@ -2,6 +2,8 @@ package packer
import (
"fmt"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
type MapOfProvisioner map[string]func() (Provisioner, error)
@ -50,14 +52,14 @@ func (mopp MapOfPostProcessor) List() []string {
return res
}
type MapOfBuilder map[string]func() (Builder, error)
type MapOfBuilder map[string]func() (packersdk.Builder, error)
func (mob MapOfBuilder) Has(builder string) bool {
_, res := mob[builder]
return res
}
func (mob MapOfBuilder) Start(builder string) (Builder, error) {
func (mob MapOfBuilder) Start(builder string) (packersdk.Builder, error) {
d, found := mob[builder]
if !found {
return nil, fmt.Errorf("Unknown builder %s", builder)

View File

@ -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 cmdBuilder struct {
builder packer.Builder
builder packersdk.Builder
client *Client
}

View File

@ -131,7 +131,7 @@ func (c *Client) Exited() bool {
// Returns a builder implementation that is communicating over this
// client. If the client hasn't been started, this will start it.
func (c *Client) Builder() (packer.Builder, error) {
func (c *Client) Builder() (packersdk.Builder, error) {
client, err := c.packrpcClient()
if err != nil {
return nil, err

View File

@ -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.Builder where the builder is actually executed
// An implementation of packersdk.Builder where the builder is actually executed
// over an RPC connection.
type builder struct {
commonClient
}
// BuilderServer wraps a packer.Builder implementation and makes it exportable
// BuilderServer wraps a packersdk.Builder implementation and makes it exportable
// as part of a Golang RPC server.
type BuilderServer struct {
context context.Context
contextCancel func()
commonServer
builder packer.Builder
builder packersdk.Builder
}
type BuilderPrepareArgs struct {

View File

@ -155,5 +155,5 @@ func TestBuilderCancel(t *testing.T) {
}
func TestBuilder_ImplementsBuilder(t *testing.T) {
var _ packer.Builder = new(builder)
var _ packersdk.Builder = new(builder)
}

View File

@ -89,7 +89,7 @@ func (c *Client) Build() packer.Build {
}
}
func (c *Client) Builder() packer.Builder {
func (c *Client) Builder() packersdk.Builder {
return &builder{
commonClient: commonClient{
endpoint: DefaultBuilderEndpoint,

View File

@ -77,7 +77,7 @@ func (s *Server) RegisterBuild(b packer.Build) error {
})
}
func (s *Server) RegisterBuilder(b packer.Builder) error {
func (s *Server) RegisterBuilder(b packersdk.Builder) error {
return s.server.RegisterName(DefaultBuilderEndpoint, &BuilderServer{
commonServer: commonServer{
selfConfigurable: b,

View File

@ -12,7 +12,7 @@ func TestCoreConfig(t *testing.T) *CoreConfig {
// Create some test components
components := ComponentFinder{
BuilderStore: MapOfBuilder{
"test": func() (Builder, error) { return &MockBuilder{}, nil },
"test": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
},
}
@ -46,7 +46,7 @@ func TestBuilder(t *testing.T, c *CoreConfig, n string) *MockBuilder {
var b MockBuilder
c.Components.BuilderStore = MapOfBuilder{
n: func() (Builder, error) { return &b, nil },
n: func() (packersdk.Builder, error) { return &b, nil },
}
return &b

View File

@ -90,7 +90,7 @@ type plugin struct {
// makeMap creates a map named Name with type packer.Name that looks something
// like this:
//
// var Builders = map[string]packer.Builder{
// var Builders = map[string]packersdk.Builder{
// "amazon-chroot": new(chroot.Builder),
// "amazon-ebs": new(ebs.Builder),
// "amazon-instance": new(instance.Builder),
@ -254,6 +254,7 @@ import (
"strings"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer/plugin"
IMPORTS