Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace build interface uses #12862

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int
packer.UiColorYellow,
packer.UiColorBlue,
}
buildUis := make(map[packersdk.Build]packersdk.Ui)
buildUis := make(map[*packer.CoreBuild]packersdk.Ui)
for i := range builds {
ui := c.Ui
if cla.Color {
Expand Down
2 changes: 1 addition & 1 deletion hcl2template/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type parseTest struct {
parseWantDiags bool
parseWantDiagHasErrors bool

getBuildsWantBuilds []packersdk.Build
getBuildsWantBuilds []*packer.CoreBuild
getBuildsWantDiags bool
// getBuildsWantDiagHasErrors bool
}
Expand Down
7 changes: 3 additions & 4 deletions hcl2template/types.build.hcp_packer_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

"github.com/hashicorp/hcl/v2"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/builder/null"
"github.com/hashicorp/packer/packer"
"github.com/zclconf/go-cty/cty"
Expand Down Expand Up @@ -50,7 +49,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -103,7 +102,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -233,7 +232,7 @@ func Test_ParseHCPPackerRegistryBlock(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
BuildName: "bucket-slug",
Type: "null.test",
Expand Down
29 changes: 14 additions & 15 deletions hcl2template/types.build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"testing"

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
. "github.com/hashicorp/packer/hcl2template/internal"
"github.com/hashicorp/packer/packer"
"github.com/zclconf/go-cty/cty"
Expand Down Expand Up @@ -55,7 +54,7 @@ func TestParse_build(t *testing.T) {
},
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
true,
},
{"untyped provisioner",
Expand Down Expand Up @@ -104,7 +103,7 @@ func TestParse_build(t *testing.T) {
},
},
true, true,
[]packersdk.Build{&packer.CoreBuild{
[]*packer.CoreBuild{&packer.CoreBuild{
Provisioners: []packer.CoreBuildProvisioner{},
}},
false,
Expand All @@ -120,7 +119,7 @@ func TestParse_build(t *testing.T) {
},
},
true, true,
[]packersdk.Build{&packer.CoreBuild{
[]*packer.CoreBuild{&packer.CoreBuild{
Builder: emptyMockBuilder,
CleanupProvisioner: packer.CoreBuildProvisioner{
PType: "shell-local",
Expand All @@ -145,7 +144,7 @@ func TestParse_build(t *testing.T) {
Builds: nil,
},
true, true,
[]packersdk.Build{&packer.CoreBuild{}},
[]*packer.CoreBuild{&packer.CoreBuild{}},
false,
},
{"nonexistent post-processor",
Expand Down Expand Up @@ -184,7 +183,7 @@ func TestParse_build(t *testing.T) {
},
},
true, true,
[]packersdk.Build{&packer.CoreBuild{
[]*packer.CoreBuild{&packer.CoreBuild{
PostProcessors: [][]packer.CoreBuildPostProcessor{},
}},
true,
Expand All @@ -198,7 +197,7 @@ func TestParse_build(t *testing.T) {
Builds: nil,
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"named build",
Expand All @@ -225,7 +224,7 @@ func TestParse_build(t *testing.T) {
},
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
true,
},
{"post-processor with only and except",
Expand Down Expand Up @@ -280,7 +279,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -395,7 +394,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -484,7 +483,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -546,7 +545,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
BuildName: "build-name",
Type: "virtualbox-iso.ubuntu-1204",
Expand All @@ -568,7 +567,7 @@ func TestParse_build(t *testing.T) {
Builds: nil,
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"use build.name in post-processor block",
Expand Down Expand Up @@ -600,7 +599,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
BuildName: "test-build",
Type: "virtualbox-iso.ubuntu-1204",
Expand Down Expand Up @@ -657,7 +656,7 @@ func TestParse_build(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
BuildName: "build-name-test",
Type: "virtualbox-iso.ubuntu-1204",
Expand Down
5 changes: 2 additions & 3 deletions hcl2template/types.datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"testing"

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/builder/null"
"github.com/hashicorp/packer/packer"
)
Expand Down Expand Up @@ -54,7 +53,7 @@ func TestParse_datasource(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "null.test",
Builder: &null.Builder{},
Expand Down Expand Up @@ -131,7 +130,7 @@ func TestParse_datasource(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "null.test",
Builder: &null.Builder{},
Expand Down
5 changes: 2 additions & 3 deletions hcl2template/types.packer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/hcl/v2/hclsyntax"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
pkrfunction "github.com/hashicorp/packer/hcl2template/function"
"github.com/hashicorp/packer/packer"
"github.com/zclconf/go-cty/cty"
Expand Down Expand Up @@ -532,8 +531,8 @@ func (cfg *PackerConfig) getCoreBuildPostProcessors(source SourceUseBlock, block
// GetBuilds returns a list of packer Build based on the HCL2 parsed build
// blocks. All Builders, Provisioners and Post Processors will be started and
// configured.
func (cfg *PackerConfig) GetBuilds(opts packer.GetBuildsOptions) ([]packersdk.Build, hcl.Diagnostics) {
res := []packersdk.Build{}
func (cfg *PackerConfig) GetBuilds(opts packer.GetBuildsOptions) ([]*packer.CoreBuild, hcl.Diagnostics) {
res := []*packer.CoreBuild{}
var diags hcl.Diagnostics
possibleBuildNames := []string{}

Expand Down
13 changes: 6 additions & 7 deletions hcl2template/types.packer_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/hashicorp/go-version"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/hcl2template/addrs"
. "github.com/hashicorp/packer/hcl2template/internal"
Expand Down Expand Up @@ -206,7 +205,7 @@ func TestParser_complete(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "virtualbox-iso.ubuntu-1204",
Prepared: true,
Expand Down Expand Up @@ -580,7 +579,7 @@ func TestParser_no_init(t *testing.T) {
Builds: nil,
},
false, false,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},

Expand All @@ -589,7 +588,7 @@ func TestParser_no_init(t *testing.T) {
parseTestArgs{"testdata/init/duplicate_required_plugins", nil, nil},
nil,
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"invalid_inexplicit_source.pkr.hcl",
Expand All @@ -609,7 +608,7 @@ func TestParser_no_init(t *testing.T) {
Basedir: filepath.Clean("testdata/init"),
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"invalid_short_source.pkr.hcl",
Expand All @@ -629,7 +628,7 @@ func TestParser_no_init(t *testing.T) {
Basedir: filepath.Clean("testdata/init"),
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"invalid_inexplicit_source_2.pkr.hcl",
Expand All @@ -649,7 +648,7 @@ func TestParser_no_init(t *testing.T) {
Basedir: filepath.Clean("testdata/init"),
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
}
Expand Down
5 changes: 2 additions & 3 deletions hcl2template/types.source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"testing"

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/builder/null"
"github.com/hashicorp/packer/packer"
)
Expand Down Expand Up @@ -52,7 +51,7 @@ func TestParse_source(t *testing.T) {
},
},
false, false,
[]packersdk.Build{
[]*packer.CoreBuild{
&packer.CoreBuild{
Type: "null.test",
Builder: &null.Builder{},
Expand Down Expand Up @@ -97,7 +96,7 @@ func TestParse_source(t *testing.T) {
},
},
true, true,
[]packersdk.Build{},
[]*packer.CoreBuild{},
false,
},
{"used source with unknown type fails",
Expand Down
Loading
Loading