commit
5e49ddb285
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
@ -240,7 +239,7 @@ func TestRun(t *testing.T) {
|
||||||
volumeId := aws.String("volume-id")
|
volumeId := aws.String("volume-id")
|
||||||
ec2Mock := defaultEc2Mock(instanceId, spotRequestId, volumeId)
|
ec2Mock := defaultEc2Mock(instanceId, spotRequestId, volumeId)
|
||||||
|
|
||||||
uiMock := packer.TestUi(t)
|
uiMock := packersdk.TestUi(t)
|
||||||
|
|
||||||
state := tStateSpot()
|
state := tStateSpot()
|
||||||
state.Put("ec2", ec2Mock)
|
state.Put("ec2", ec2Mock)
|
||||||
|
@ -332,7 +331,7 @@ func TestRun_NoSpotTags(t *testing.T) {
|
||||||
volumeId := aws.String("volume-id")
|
volumeId := aws.String("volume-id")
|
||||||
ec2Mock := defaultEc2Mock(instanceId, spotRequestId, volumeId)
|
ec2Mock := defaultEc2Mock(instanceId, spotRequestId, volumeId)
|
||||||
|
|
||||||
uiMock := packer.TestUi(t)
|
uiMock := packersdk.TestUi(t)
|
||||||
|
|
||||||
state := tStateSpot()
|
state := tStateSpot()
|
||||||
state.Put("ec2", ec2Mock)
|
state.Put("ec2", ec2Mock)
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs"
|
amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
testshelper "github.com/hashicorp/packer/helper/tests"
|
testshelper "github.com/hashicorp/packer/helper/tests"
|
||||||
|
@ -55,8 +54,8 @@ func (s *AmazonEBSAccTest) CleanUp() error {
|
||||||
return helper.CleanUpAmi()
|
return helper.CleanUpAmi()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AmazonEBSAccTest) GetBuilderStore() packer.MapOfBuilder {
|
func (s *AmazonEBSAccTest) GetBuilderStore() packersdk.MapOfBuilder {
|
||||||
return packer.MapOfBuilder{
|
return packersdk.MapOfBuilder{
|
||||||
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
|
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
@ -116,7 +116,7 @@ func TestStepCreateImage_Run(t *testing.T) {
|
||||||
state.Put("azureclient", &client.AzureClientSetMock{
|
state.Put("azureclient", &client.AzureClientSetMock{
|
||||||
ImagesClientMock: ic,
|
ImagesClientMock: ic,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put(stateBagKey_Diskset, tt.diskset)
|
state.Put(stateBagKey_Diskset, tt.diskset)
|
||||||
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
@ -224,7 +224,7 @@ func TestStepCreateNewDisk_Run(t *testing.T) {
|
||||||
DisksClientMock: m,
|
DisksClientMock: m,
|
||||||
GalleryImageVersionsClientMock: giv,
|
GalleryImageVersionsClientMock: giv,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
|
|
||||||
if got := s.Run(context.TODO(), state); !reflect.DeepEqual(got, tt.want) {
|
if got := s.Run(context.TODO(), state); !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("StepCreateNewDisk.Run() = %v, want %v", got, tt.want)
|
t.Errorf("StepCreateNewDisk.Run() = %v, want %v", got, tt.want)
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
@ -126,7 +126,7 @@ func TestStepCreateSharedImageVersion_Run(t *testing.T) {
|
||||||
state.Put("azureclient", &client.AzureClientSetMock{
|
state.Put("azureclient", &client.AzureClientSetMock{
|
||||||
GalleryImageVersionsClientMock: m,
|
GalleryImageVersionsClientMock: m,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put(stateBagKey_Snapshotset, tt.snapshotset)
|
state.Put(stateBagKey_Snapshotset, tt.snapshotset)
|
||||||
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStepCreateSnapshot_Run(t *testing.T) {
|
func TestStepCreateSnapshot_Run(t *testing.T) {
|
||||||
|
@ -101,7 +101,7 @@ func TestStepCreateSnapshot_Run(t *testing.T) {
|
||||||
state.Put("azureclient", &client.AzureClientSetMock{
|
state.Put("azureclient", &client.AzureClientSetMock{
|
||||||
SnapshotsClientMock: m,
|
SnapshotsClientMock: m,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put(stateBagKey_Diskset, tt.diskset)
|
state.Put(stateBagKey_Diskset, tt.diskset)
|
||||||
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
@ -136,7 +136,7 @@ func TestStepCreateSnapshot_Cleanup_skipped(t *testing.T) {
|
||||||
state.Put("azureclient", &client.AzureClientSetMock{
|
state.Put("azureclient", &client.AzureClientSetMock{
|
||||||
SnapshotsClientMock: m,
|
SnapshotsClientMock: m,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
|
|
||||||
s := &StepCreateSnapshotset{
|
s := &StepCreateSnapshotset{
|
||||||
SkipCleanup: true,
|
SkipCleanup: true,
|
||||||
|
@ -185,7 +185,7 @@ func TestStepCreateSnapshot_Cleanup(t *testing.T) {
|
||||||
state.Put("azureclient", &client.AzureClientSetMock{
|
state.Put("azureclient", &client.AzureClientSetMock{
|
||||||
SnapshotsClientMock: m,
|
SnapshotsClientMock: m,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
|
|
||||||
s := &StepCreateSnapshotset{
|
s := &StepCreateSnapshotset{
|
||||||
SkipCleanup: false,
|
SkipCleanup: false,
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
@ -164,7 +164,7 @@ func TestStepVerifySharedImageDestination_Run(t *testing.T) {
|
||||||
GalleryImagesClientMock: gi,
|
GalleryImagesClientMock: gi,
|
||||||
GalleryImageVersionsClientMock: giv,
|
GalleryImageVersionsClientMock: giv,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
s := &StepVerifySharedImageDestination{
|
s := &StepVerifySharedImageDestination{
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/hashicorp/packer/builder/azure/common/client"
|
"github.com/hashicorp/packer/builder/azure/common/client"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStepVerifySharedImageSource_Run(t *testing.T) {
|
func TestStepVerifySharedImageSource_Run(t *testing.T) {
|
||||||
|
@ -163,7 +163,7 @@ func TestStepVerifySharedImageSource_Run(t *testing.T) {
|
||||||
GalleryImageVersionsClientMock: giv,
|
GalleryImageVersionsClientMock: giv,
|
||||||
GalleryImagesClientMock: gi,
|
GalleryImagesClientMock: gi,
|
||||||
})
|
})
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
s := &StepVerifySharedImageSource{
|
s := &StepVerifySharedImageSource{
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
|
|
||||||
// TestUploadDownload verifies that basic upload / download functionality works
|
// TestUploadDownload verifies that basic upload / download functionality works
|
||||||
func TestUploadDownload(t *testing.T) {
|
func TestUploadDownload(t *testing.T) {
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
tpl, err := template.Parse(strings.NewReader(dockerBuilderConfig))
|
tpl, err := template.Parse(strings.NewReader(dockerBuilderConfig))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -101,7 +101,7 @@ func TestUploadDownload(t *testing.T) {
|
||||||
// need to use github.com/cbednarski/rerun to verify since this problem occurs
|
// need to use github.com/cbednarski/rerun to verify since this problem occurs
|
||||||
// only intermittently.
|
// only intermittently.
|
||||||
func TestLargeDownload(t *testing.T) {
|
func TestLargeDownload(t *testing.T) {
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
tpl, err := template.Parse(strings.NewReader(dockerLargeBuilderConfig))
|
tpl, err := template.Parse(strings.NewReader(dockerLargeBuilderConfig))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -205,7 +205,7 @@ func TestLargeDownload(t *testing.T) {
|
||||||
|
|
||||||
// TestFixUploadOwner verifies that owner of uploaded files is the user the container is running as.
|
// TestFixUploadOwner verifies that owner of uploaded files is the user the container is running as.
|
||||||
func TestFixUploadOwner(t *testing.T) {
|
func TestFixUploadOwner(t *testing.T) {
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
tpl, err := template.Parse(strings.NewReader(testFixUploadOwnerTemplate))
|
tpl, err := template.Parse(strings.NewReader(testFixUploadOwnerTemplate))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
|
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ func testConfig() map[string]interface{} {
|
||||||
"disk_block_size": 1,
|
"disk_block_size": 1,
|
||||||
"guest_additions_mode": "none",
|
"guest_additions_mode": "none",
|
||||||
"disk_additional_size": "50000,40000,30000",
|
"disk_additional_size": "50000,40000,30000",
|
||||||
packer.BuildNameConfigKey: "foo",
|
common.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ func TestUserVariablesInBootCommand(t *testing.T) {
|
||||||
var b Builder
|
var b Builder
|
||||||
config := testConfig()
|
config := testConfig()
|
||||||
|
|
||||||
config[packer.UserVariablesConfigKey] = map[string]string{"test-variable": "test"}
|
config[common.UserVariablesConfigKey] = map[string]string{"test-variable": "test"}
|
||||||
config["boot_command"] = []string{"blah {{user `test-variable`}} blah"}
|
config["boot_command"] = []string{"blah {{user `test-variable`}} blah"}
|
||||||
|
|
||||||
_, warns, err := b.Prepare(config)
|
_, warns, err := b.Prepare(config)
|
||||||
|
@ -602,7 +602,7 @@ func TestUserVariablesInBootCommand(t *testing.T) {
|
||||||
t.Fatalf("should not have error: %s", err)
|
t.Fatalf("should not have error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
hook := &packersdk.MockHook{}
|
hook := &packersdk.MockHook{}
|
||||||
driver := &hypervcommon.DriverMock{}
|
driver := &hypervcommon.DriverMock{}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
|
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ func testConfig() map[string]interface{} {
|
||||||
"memory": 64,
|
"memory": 64,
|
||||||
"guest_additions_mode": "none",
|
"guest_additions_mode": "none",
|
||||||
"clone_from_vmcx_path": "generated",
|
"clone_from_vmcx_path": "generated",
|
||||||
packer.BuildNameConfigKey: "foo",
|
common.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ func TestUserVariablesInBootCommand(t *testing.T) {
|
||||||
defer os.RemoveAll(td)
|
defer os.RemoveAll(td)
|
||||||
config["clone_from_vmcx_path"] = td
|
config["clone_from_vmcx_path"] = td
|
||||||
|
|
||||||
config[packer.UserVariablesConfigKey] = map[string]string{"test-variable": "test"}
|
config[common.UserVariablesConfigKey] = map[string]string{"test-variable": "test"}
|
||||||
config["boot_command"] = []string{"blah {{user `test-variable`}} blah"}
|
config["boot_command"] = []string{"blah {{user `test-variable`}} blah"}
|
||||||
|
|
||||||
_, warns, err := b.Prepare(config)
|
_, warns, err := b.Prepare(config)
|
||||||
|
@ -494,7 +494,7 @@ func TestUserVariablesInBootCommand(t *testing.T) {
|
||||||
t.Fatalf("should not have error: %s", err)
|
t.Fatalf("should not have error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
hook := &packersdk.MockHook{}
|
hook := &packersdk.MockHook{}
|
||||||
driver := &hypervcommon.DriverMock{}
|
driver := &hypervcommon.DriverMock{}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ func testConfig() map[string]interface{} {
|
||||||
"ssh_username": "foo",
|
"ssh_username": "foo",
|
||||||
"parallels_tools_flavor": "lin",
|
"parallels_tools_flavor": "lin",
|
||||||
|
|
||||||
packer.BuildNameConfigKey: "foo",
|
common.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Telmate/proxmox-api-go/proxmox"
|
"github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type converterMock struct {
|
type converterMock struct {
|
||||||
|
@ -79,7 +79,7 @@ func TestConvertToTemplate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("vmRef", proxmox.NewVmRef(vmid))
|
state.Put("vmRef", proxmox.NewVmRef(vmid))
|
||||||
state.Put("proxmoxClient", converter)
|
state.Put("proxmoxClient", converter)
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Telmate/proxmox-api-go/proxmox"
|
"github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type finalizerMock struct {
|
type finalizerMock struct {
|
||||||
|
@ -157,7 +157,7 @@ func TestTemplateFinalize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("config", c.builderConfig)
|
state.Put("config", c.builderConfig)
|
||||||
state.Put("vmRef", proxmox.NewVmRef(1))
|
state.Put("vmRef", proxmox.NewVmRef(1))
|
||||||
state.Put("proxmoxClient", finalizer)
|
state.Put("proxmoxClient", finalizer)
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Telmate/proxmox-api-go/proxmox"
|
"github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type startedVMCleanerMock struct {
|
type startedVMCleanerMock struct {
|
||||||
|
@ -85,7 +85,7 @@ func TestCleanupStartVM(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("proxmoxClient", cleaner)
|
state.Put("proxmoxClient", cleaner)
|
||||||
if c.setVmRef {
|
if c.setVmRef {
|
||||||
state.Put("vmRef", proxmox.NewVmRef(1))
|
state.Put("vmRef", proxmox.NewVmRef(1))
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Telmate/proxmox-api-go/proxmox"
|
"github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
|
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type commandTyperMock struct {
|
type commandTyperMock struct {
|
||||||
|
@ -128,7 +128,7 @@ func TestTypeBootCommand(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("config", c.builderConfig)
|
state.Put("config", c.builderConfig)
|
||||||
state.Put("http_port", int(0))
|
state.Put("http_port", int(0))
|
||||||
state.Put("vmRef", proxmox.NewVmRef(1))
|
state.Put("vmRef", proxmox.NewVmRef(1))
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Telmate/proxmox-api-go/proxmox"
|
"github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type finalizerMock struct {
|
type finalizerMock struct {
|
||||||
|
@ -116,7 +116,7 @@ func TestISOTemplateFinalize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("iso-config", c.builderConfig)
|
state.Put("iso-config", c.builderConfig)
|
||||||
state.Put("vmRef", proxmox.NewVmRef(1))
|
state.Put("vmRef", proxmox.NewVmRef(1))
|
||||||
state.Put("proxmoxClient", finalizer)
|
state.Put("proxmoxClient", finalizer)
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type uploaderMock struct {
|
type uploaderMock struct {
|
||||||
|
@ -105,7 +105,7 @@ func TestUploadISO(t *testing.T) {
|
||||||
m := &uploaderMock{fail: c.failUpload}
|
m := &uploaderMock{fail: c.failUpload}
|
||||||
|
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("iso-config", c.builderConfig)
|
state.Put("iso-config", c.builderConfig)
|
||||||
state.Put(downloadPathKey, c.downloadPath)
|
state.Put(downloadPathKey, c.downloadPath)
|
||||||
state.Put("proxmoxClient", m)
|
state.Put("proxmoxClient", m)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,7 @@ func testConfig() map[string]interface{} {
|
||||||
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
|
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
|
||||||
"iso_url": "http://www.google.com/",
|
"iso_url": "http://www.google.com/",
|
||||||
"ssh_username": "foo",
|
"ssh_username": "foo",
|
||||||
packer.BuildNameConfigKey: "foo",
|
common.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func copyTestState(t *testing.T, d *DriverMock) multistep.StateBag {
|
func copyTestState(t *testing.T, d *DriverMock) multistep.StateBag {
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
state.Put("driver", d)
|
state.Put("driver", d)
|
||||||
state.Put("iso_path", "example_source.qcow2")
|
state.Put("iso_path", "example_source.qcow2")
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ func Test_UserOverrides(t *testing.T) {
|
||||||
|
|
||||||
step := &stepRun{
|
step := &stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
}
|
}
|
||||||
args, err := step.getCommandArgs(tc.Config, state)
|
args, err := step.getCommandArgs(tc.Config, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -130,7 +130,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -155,7 +155,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
&stepRun{
|
&stepRun{
|
||||||
DiskImage: true,
|
DiskImage: true,
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -183,7 +183,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
&stepRun{
|
&stepRun{
|
||||||
DiskImage: true,
|
DiskImage: true,
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -212,7 +212,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -244,7 +244,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -274,7 +274,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -294,7 +294,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -314,7 +314,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -338,7 +338,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: false,
|
atLeastVersion2: false,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-boot", "once=d",
|
"-boot", "once=d",
|
||||||
|
@ -360,7 +360,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
},
|
},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -386,7 +386,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) {
|
||||||
&stepRun{
|
&stepRun{
|
||||||
DiskImage: true,
|
DiskImage: true,
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"-display", "gtk",
|
"-display", "gtk",
|
||||||
|
@ -436,7 +436,7 @@ func Test_OptionalConfigOptionsGetSet(t *testing.T) {
|
||||||
state := runTestState(t, c)
|
state := runTestState(t, c)
|
||||||
step := &stepRun{
|
step := &stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
}
|
}
|
||||||
args, err := step.getCommandArgs(c, state)
|
args, err := step.getCommandArgs(c, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -475,7 +475,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
{
|
{
|
||||||
&Config{},
|
&Config{},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-boot", "once=d"},
|
[]string{"-boot", "once=d"},
|
||||||
"Boot value should default to once=d",
|
"Boot value should default to once=d",
|
||||||
},
|
},
|
||||||
|
@ -484,7 +484,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
DiskImage: true,
|
DiskImage: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{"-boot", "c"},
|
[]string{"-boot", "c"},
|
||||||
"Boot value should be set to c when DiskImage is set on step",
|
"Boot value should be set to c when DiskImage is set on step",
|
||||||
|
@ -495,7 +495,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
QMPSocketPath: "/path/to/socket",
|
QMPSocketPath: "/path/to/socket",
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-qmp", "unix:/path/to/socket,server,nowait"},
|
[]string{"-qmp", "unix:/path/to/socket,server,nowait"},
|
||||||
"Args should contain -qmp when qmp_enable is set",
|
"Args should contain -qmp when qmp_enable is set",
|
||||||
},
|
},
|
||||||
|
@ -504,7 +504,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
QMPEnable: true,
|
QMPEnable: true,
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-qmp", "unix:,server,nowait"},
|
[]string{"-qmp", "unix:,server,nowait"},
|
||||||
"Args contain -qmp even when socket path isn't set, if qmp enabled",
|
"Args contain -qmp even when socket path isn't set, if qmp enabled",
|
||||||
},
|
},
|
||||||
|
@ -513,14 +513,14 @@ func Test_Defaults(t *testing.T) {
|
||||||
VMName: "partyname",
|
VMName: "partyname",
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-name", "partyname"},
|
[]string{"-name", "partyname"},
|
||||||
"Name is set from config",
|
"Name is set from config",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
&Config{},
|
&Config{},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-name", ""},
|
[]string{"-name", ""},
|
||||||
"Name is set from config, even when name is blank (which won't " +
|
"Name is set from config, even when name is blank (which won't " +
|
||||||
"happen for real thanks to defaulting in build prepare)",
|
"happen for real thanks to defaulting in build prepare)",
|
||||||
|
@ -531,7 +531,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
MachineType: "fancymachine",
|
MachineType: "fancymachine",
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-machine", "type=fancymachine"},
|
[]string{"-machine", "type=fancymachine"},
|
||||||
"Don't add accelerator tag when no accelerator is set.",
|
"Don't add accelerator tag when no accelerator is set.",
|
||||||
},
|
},
|
||||||
|
@ -541,7 +541,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
MachineType: "fancymachine",
|
MachineType: "fancymachine",
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-machine", "type=fancymachine,accel=kvm"},
|
[]string{"-machine", "type=fancymachine,accel=kvm"},
|
||||||
"Add accelerator tag when accelerator is set.",
|
"Add accelerator tag when accelerator is set.",
|
||||||
},
|
},
|
||||||
|
@ -550,7 +550,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
NetBridge: "fakebridge",
|
NetBridge: "fakebridge",
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-netdev", "bridge,id=user.0,br=fakebridge"},
|
[]string{"-netdev", "bridge,id=user.0,br=fakebridge"},
|
||||||
"Add netbridge tag when netbridge is set.",
|
"Add netbridge tag when netbridge is set.",
|
||||||
},
|
},
|
||||||
|
@ -563,7 +563,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-netdev", "user,id=user.0"},
|
[]string{"-netdev", "user,id=user.0"},
|
||||||
"No host forwarding when no net bridge and no communicator",
|
"No host forwarding when no net bridge and no communicator",
|
||||||
},
|
},
|
||||||
|
@ -581,7 +581,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"commHostPort": 1111,
|
"commHostPort": 1111,
|
||||||
},
|
},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-netdev", "user,id=user.0,hostfwd=tcp::1111-:4567"},
|
[]string{"-netdev", "user,id=user.0,hostfwd=tcp::1111-:4567"},
|
||||||
"Host forwarding when a communicator is configured",
|
"Host forwarding when a communicator is configured",
|
||||||
},
|
},
|
||||||
|
@ -592,7 +592,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"vnc_port": 5959,
|
"vnc_port": 5959,
|
||||||
},
|
},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-vnc", "1.1.1.1:5959"},
|
[]string{"-vnc", "1.1.1.1:5959"},
|
||||||
"no VNC password should be set",
|
"no VNC password should be set",
|
||||||
},
|
},
|
||||||
|
@ -604,7 +604,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"vnc_port": 5959,
|
"vnc_port": 5959,
|
||||||
},
|
},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-vnc", "1.1.1.1:5959,password"},
|
[]string{"-vnc", "1.1.1.1:5959,password"},
|
||||||
"VNC password should be set",
|
"VNC password should be set",
|
||||||
},
|
},
|
||||||
|
@ -613,7 +613,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
MemorySize: 2345,
|
MemorySize: 2345,
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-m", "2345M"},
|
[]string{"-m", "2345M"},
|
||||||
"Memory is set, with unit M",
|
"Memory is set, with unit M",
|
||||||
},
|
},
|
||||||
|
@ -622,7 +622,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
CpuCount: 2,
|
CpuCount: 2,
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-smp", "cpus=2,sockets=2"},
|
[]string{"-smp", "cpus=2,sockets=2"},
|
||||||
"both cpus and sockets are set to config's CpuCount",
|
"both cpus and sockets are set to config's CpuCount",
|
||||||
},
|
},
|
||||||
|
@ -631,7 +631,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
CpuCount: 2,
|
CpuCount: 2,
|
||||||
},
|
},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-smp", "cpus=2,sockets=2"},
|
[]string{"-smp", "cpus=2,sockets=2"},
|
||||||
"both cpus and sockets are set to config's CpuCount",
|
"both cpus and sockets are set to config's CpuCount",
|
||||||
},
|
},
|
||||||
|
@ -642,7 +642,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"floppy_path": "/path/to/floppy",
|
"floppy_path": "/path/to/floppy",
|
||||||
},
|
},
|
||||||
&stepRun{ui: packer.TestUi(t)},
|
&stepRun{ui: packersdk.TestUi(t)},
|
||||||
[]string{"-fda", "/path/to/floppy"},
|
[]string{"-fda", "/path/to/floppy"},
|
||||||
"floppy path should be set under fda flag, when it exists",
|
"floppy path should be set under fda flag, when it exists",
|
||||||
},
|
},
|
||||||
|
@ -655,7 +655,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{"-display", "fakedisplay"},
|
[]string{"-display", "fakedisplay"},
|
||||||
"Display option should value config display",
|
"Display option should value config display",
|
||||||
|
@ -667,7 +667,7 @@ func Test_Defaults(t *testing.T) {
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
&stepRun{
|
&stepRun{
|
||||||
atLeastVersion2: true,
|
atLeastVersion2: true,
|
||||||
ui: packer.TestUi(t),
|
ui: packersdk.TestUi(t),
|
||||||
},
|
},
|
||||||
[]string{"-display", "gtk"},
|
[]string{"-display", "gtk"},
|
||||||
"Display option should default to gtk",
|
"Display option should default to gtk",
|
||||||
|
|
|
@ -5,14 +5,14 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Shutdown_Null_success(t *testing.T) {
|
func Test_Shutdown_Null_success(t *testing.T) {
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
driverMock := new(DriverMock)
|
driverMock := new(DriverMock)
|
||||||
driverMock.WaitForShutdownState = true
|
driverMock.WaitForShutdownState = true
|
||||||
state.Put("driver", driverMock)
|
state.Put("driver", driverMock)
|
||||||
|
@ -37,7 +37,7 @@ func Test_Shutdown_Null_success(t *testing.T) {
|
||||||
|
|
||||||
func Test_Shutdown_Null_failure(t *testing.T) {
|
func Test_Shutdown_Null_failure(t *testing.T) {
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
driverMock := new(DriverMock)
|
driverMock := new(DriverMock)
|
||||||
driverMock.WaitForShutdownState = false
|
driverMock.WaitForShutdownState = false
|
||||||
state.Put("driver", driverMock)
|
state.Put("driver", driverMock)
|
||||||
|
@ -61,7 +61,7 @@ func Test_Shutdown_Null_failure(t *testing.T) {
|
||||||
|
|
||||||
func Test_Shutdown_NoShutdownCommand(t *testing.T) {
|
func Test_Shutdown_NoShutdownCommand(t *testing.T) {
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
state.Put("ui", packer.TestUi(t))
|
state.Put("ui", packersdk.TestUi(t))
|
||||||
driverMock := new(DriverMock)
|
driverMock := new(DriverMock)
|
||||||
state.Put("driver", driverMock)
|
state.Put("driver", driverMock)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/virtualbox/iso"
|
"github.com/hashicorp/packer/builder/virtualbox/iso"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
testshelper "github.com/hashicorp/packer/helper/tests"
|
testshelper "github.com/hashicorp/packer/helper/tests"
|
||||||
|
@ -40,8 +39,8 @@ func (v *VirtualBoxISOAccTest) CleanUp() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VirtualBoxISOAccTest) GetBuilderStore() packer.MapOfBuilder {
|
func (v *VirtualBoxISOAccTest) GetBuilderStore() packersdk.MapOfBuilder {
|
||||||
return packer.MapOfBuilder{
|
return packersdk.MapOfBuilder{
|
||||||
"virtualbox-iso": func() (packersdk.Builder, error) { return &iso.Builder{}, nil },
|
"virtualbox-iso": func() (packersdk.Builder, error) { return &iso.Builder{}, nil },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/virtualbox/common"
|
"github.com/hashicorp/packer/builder/virtualbox/common"
|
||||||
"github.com/hashicorp/packer/packer"
|
packercommon "github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ func testConfig() map[string]interface{} {
|
||||||
"shutdown_command": "yes",
|
"shutdown_command": "yes",
|
||||||
"ssh_username": "foo",
|
"ssh_username": "foo",
|
||||||
|
|
||||||
packer.BuildNameConfigKey: "foo",
|
packercommon.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ func testConfig() map[string]interface{} {
|
||||||
"shutdown_command": "foo",
|
"shutdown_command": "foo",
|
||||||
"ssh_username": "foo",
|
"ssh_username": "foo",
|
||||||
|
|
||||||
packer.BuildNameConfigKey: "foo",
|
common.BuildNameConfigKey: "foo",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ func readFloppyOutput(path string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisionerConfig map[string]string) error {
|
func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisionerConfig map[string]string) error {
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
// create builder config and update with user-supplied options
|
// create builder config and update with user-supplied options
|
||||||
cfgBuilder := map[string]string{}
|
cfgBuilder := map[string]string{}
|
||||||
|
@ -138,16 +138,16 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner
|
||||||
|
|
||||||
// create our config to test the vmware-iso builder
|
// create our config to test the vmware-iso builder
|
||||||
components := packer.ComponentFinder{
|
components := packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"vmware-iso": func() (packersdk.Builder, error) { return &Builder{}, nil },
|
"vmware-iso": func() (packersdk.Builder, error) { return &Builder{}, nil },
|
||||||
},
|
},
|
||||||
Hook: func(n string) (packersdk.Hook, error) {
|
Hook: func(n string) (packersdk.Hook, error) {
|
||||||
return &packersdk.DispatchHook{}, nil
|
return &packersdk.DispatchHook{}, nil
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
PostProcessorStore: packer.MapOfPostProcessor{
|
PostProcessorStore: packersdk.MapOfPostProcessor{
|
||||||
"something": func() (packersdk.PostProcessor, error) { return &packer.MockPostProcessor{}, nil },
|
"something": func() (packersdk.PostProcessor, error) { return &packer.MockPostProcessor{}, nil },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,12 @@ func testMetaParallel(t *testing.T, builder *ParallelTestBuilder, locked *Locked
|
||||||
return Meta{
|
return Meta{
|
||||||
CoreConfig: &packer.CoreConfig{
|
CoreConfig: &packer.CoreConfig{
|
||||||
Components: packer.ComponentFinder{
|
Components: packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"parallel-test": func() (packersdk.Builder, error) { return builder, nil },
|
"parallel-test": func() (packersdk.Builder, error) { return builder, nil },
|
||||||
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
||||||
"lock": func() (packersdk.Builder, error) { return locked, nil },
|
"lock": func() (packersdk.Builder, error) { return locked, nil },
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"sleep": func() (packersdk.Provisioner, error) { return &sleep.Provisioner{}, nil },
|
"sleep": func() (packersdk.Provisioner, error) { return &sleep.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -836,16 +836,16 @@ func fileExists(filename string) bool {
|
||||||
// available. This allows us to test a builder that writes files to disk.
|
// available. This allows us to test a builder that writes files to disk.
|
||||||
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
|
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
|
||||||
components := packer.ComponentFinder{
|
components := packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
||||||
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
|
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
"file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil },
|
"file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
PostProcessorStore: packer.MapOfPostProcessor{
|
PostProcessorStore: packersdk.MapOfPostProcessor{
|
||||||
"shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil },
|
"shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil },
|
||||||
"manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil },
|
"manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil },
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,10 +16,10 @@ import (
|
||||||
// available. This allows us to test a builder that writes files to disk.
|
// available. This allows us to test a builder that writes files to disk.
|
||||||
func testCoreConfigSleepBuilder(t *testing.T) *packer.CoreConfig {
|
func testCoreConfigSleepBuilder(t *testing.T) *packer.CoreConfig {
|
||||||
components := packer.ComponentFinder{
|
components := packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"sleep": func() (packersdk.Provisioner, error) { return &sleep.Provisioner{}, nil },
|
"sleep": func() (packersdk.Provisioner, error) { return &sleep.Provisioner{}, nil },
|
||||||
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
|
|
|
@ -118,17 +118,17 @@ func commandMeta() Meta {
|
||||||
|
|
||||||
func getBareComponentFinder() packer.ComponentFinder {
|
func getBareComponentFinder() packer.ComponentFinder {
|
||||||
return packer.ComponentFinder{
|
return packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
||||||
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
|
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
|
||||||
"amazon-ebs": func() (packersdk.Builder, error) { return &ebs.Builder{}, nil },
|
"amazon-ebs": func() (packersdk.Builder, error) { return &ebs.Builder{}, nil },
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
"file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil },
|
"file": func() (packersdk.Provisioner, error) { return &filep.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
PostProcessorStore: packer.MapOfPostProcessor{
|
PostProcessorStore: packersdk.MapOfPostProcessor{
|
||||||
"shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil },
|
"shell-local": func() (packersdk.PostProcessor, error) { return &shell_local_pp.PostProcessor{}, nil },
|
||||||
"manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil },
|
"manifest": func() (packersdk.PostProcessor, error) { return &manifest.PostProcessor{}, nil },
|
||||||
},
|
},
|
||||||
|
|
17
config.go
17
config.go
|
@ -12,7 +12,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/packer/plugin"
|
"github.com/hashicorp/packer/packer/plugin"
|
||||||
)
|
)
|
||||||
|
@ -22,14 +21,14 @@ import (
|
||||||
const PACKERSPACE = "-PACKERSPACE-"
|
const PACKERSPACE = "-PACKERSPACE-"
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
DisableCheckpoint bool `json:"disable_checkpoint"`
|
DisableCheckpoint bool `json:"disable_checkpoint"`
|
||||||
DisableCheckpointSignature bool `json:"disable_checkpoint_signature"`
|
DisableCheckpointSignature bool `json:"disable_checkpoint_signature"`
|
||||||
RawBuilders map[string]string `json:"builders"`
|
RawBuilders map[string]string `json:"builders"`
|
||||||
RawProvisioners map[string]string `json:"provisioners"`
|
RawProvisioners map[string]string `json:"provisioners"`
|
||||||
RawPostProcessors map[string]string `json:"post-processors"`
|
RawPostProcessors map[string]string `json:"post-processors"`
|
||||||
Builders packer.MapOfBuilder `json:"-"`
|
Builders packersdk.MapOfBuilder `json:"-"`
|
||||||
Provisioners packer.MapOfProvisioner `json:"-"`
|
Provisioners packersdk.MapOfProvisioner `json:"-"`
|
||||||
PostProcessors packer.MapOfPostProcessor `json:"-"`
|
PostProcessors packersdk.MapOfPostProcessor `json:"-"`
|
||||||
Plugins plugin.Config
|
Plugins plugin.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecodeConfig(t *testing.T) {
|
func TestDecodeConfig(t *testing.T) {
|
||||||
|
@ -49,9 +49,9 @@ func TestLoadExternalComponentsFromConfig(t *testing.T) {
|
||||||
defer cleanUpFunc()
|
defer cleanUpFunc()
|
||||||
|
|
||||||
var cfg config
|
var cfg config
|
||||||
cfg.Builders = packer.MapOfBuilder{}
|
cfg.Builders = packersdk.MapOfBuilder{}
|
||||||
cfg.PostProcessors = packer.MapOfPostProcessor{}
|
cfg.PostProcessors = packersdk.MapOfPostProcessor{}
|
||||||
cfg.Provisioners = packer.MapOfProvisioner{}
|
cfg.Provisioners = packersdk.MapOfProvisioner{}
|
||||||
|
|
||||||
if err := decodeConfig(strings.NewReader(packerConfigData), &cfg); err != nil {
|
if err := decodeConfig(strings.NewReader(packerConfigData), &cfg); err != nil {
|
||||||
t.Fatalf("error encountered decoding configuration: %v", err)
|
t.Fatalf("error encountered decoding configuration: %v", err)
|
||||||
|
@ -81,7 +81,7 @@ func TestLoadExternalComponentsFromConfig_onlyProvisioner(t *testing.T) {
|
||||||
defer cleanUpFunc()
|
defer cleanUpFunc()
|
||||||
|
|
||||||
var cfg config
|
var cfg config
|
||||||
cfg.Provisioners = packer.MapOfProvisioner{}
|
cfg.Provisioners = packersdk.MapOfProvisioner{}
|
||||||
|
|
||||||
if err := decodeConfig(strings.NewReader(packerConfigData), &cfg); err != nil {
|
if err := decodeConfig(strings.NewReader(packerConfigData), &cfg); err != nil {
|
||||||
t.Fatalf("error encountered decoding configuration: %v", err)
|
t.Fatalf("error encountered decoding configuration: %v", err)
|
||||||
|
@ -126,9 +126,9 @@ func TestLoadSingleComponent(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg config
|
var cfg config
|
||||||
cfg.Builders = packer.MapOfBuilder{}
|
cfg.Builders = packersdk.MapOfBuilder{}
|
||||||
cfg.PostProcessors = packer.MapOfPostProcessor{}
|
cfg.PostProcessors = packersdk.MapOfPostProcessor{}
|
||||||
cfg.Provisioners = packer.MapOfProvisioner{}
|
cfg.Provisioners = packersdk.MapOfProvisioner{}
|
||||||
|
|
||||||
for _, tc := range tt {
|
for _, tc := range tt {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
|
|
@ -20,16 +20,16 @@ import (
|
||||||
func getBasicParser() *Parser {
|
func getBasicParser() *Parser {
|
||||||
return &Parser{
|
return &Parser{
|
||||||
Parser: hclparse.NewParser(),
|
Parser: hclparse.NewParser(),
|
||||||
BuilderSchemas: packer.MapOfBuilder{
|
BuilderSchemas: packersdk.MapOfBuilder{
|
||||||
"amazon-ebs": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
|
"amazon-ebs": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
|
||||||
"virtualbox-iso": 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 },
|
"null": func() (packersdk.Builder, error) { return &null.Builder{}, nil },
|
||||||
},
|
},
|
||||||
ProvisionersSchemas: packer.MapOfProvisioner{
|
ProvisionersSchemas: packersdk.MapOfProvisioner{
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &MockProvisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &MockProvisioner{}, nil },
|
||||||
"file": func() (packersdk.Provisioner, error) { return &MockProvisioner{}, nil },
|
"file": func() (packersdk.Provisioner, error) { return &MockProvisioner{}, nil },
|
||||||
},
|
},
|
||||||
PostProcessorsSchemas: packer.MapOfPostProcessor{
|
PostProcessorsSchemas: packersdk.MapOfPostProcessor{
|
||||||
"amazon-import": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil },
|
"amazon-import": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil },
|
||||||
"manifest": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil },
|
"manifest": func() (packersdk.PostProcessor, error) { return &MockPostProcessor{}, nil },
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
amazonEBS "github.com/hashicorp/packer/builder/amazon/ebs/acceptance"
|
amazonEBS "github.com/hashicorp/packer/builder/amazon/ebs/acceptance"
|
||||||
virtualboxISO "github.com/hashicorp/packer/builder/virtualbox/iso/acceptance"
|
virtualboxISO "github.com/hashicorp/packer/builder/virtualbox/iso/acceptance"
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
"github.com/hashicorp/packer/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProvisionersAgainstBuilders(provisionerAcc ProvisionerAcceptance, t *testing.T) {
|
func TestProvisionersAgainstBuilders(provisionerAcc ProvisionerAcceptance, t *testing.T) {
|
||||||
|
@ -133,14 +133,14 @@ func buildCommand(t *testing.T, builder BuilderAcceptance, provisioner Provision
|
||||||
type ProvisionerAcceptance interface {
|
type ProvisionerAcceptance interface {
|
||||||
GetName() string
|
GetName() string
|
||||||
GetConfig() (string, error)
|
GetConfig() (string, error)
|
||||||
GetProvisionerStore() packer.MapOfProvisioner
|
GetProvisionerStore() packersdk.MapOfProvisioner
|
||||||
IsCompatible(builder string, vmOS string) bool
|
IsCompatible(builder string, vmOS string) bool
|
||||||
RunTest(c *command.BuildCommand, args []string) error
|
RunTest(c *command.BuildCommand, args []string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type BuilderAcceptance interface {
|
type BuilderAcceptance interface {
|
||||||
GetConfigs() (map[string]string, error)
|
GetConfigs() (map[string]string, error)
|
||||||
GetBuilderStore() packer.MapOfBuilder
|
GetBuilderStore() packersdk.MapOfBuilder
|
||||||
CleanUp() error
|
CleanUp() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@ func FileExists(filename string) bool {
|
||||||
// available. This allows us to test a builder that writes files to disk.
|
// available. This allows us to test a builder that writes files to disk.
|
||||||
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
|
func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig {
|
||||||
components := packer.ComponentFinder{
|
components := packer.ComponentFinder{
|
||||||
BuilderStore: packer.MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
|
"amazon-ebs": func() (packersdk.Builder, error) { return &amazonebsbuilder.Builder{}, nil },
|
||||||
},
|
},
|
||||||
ProvisionerStore: packer.MapOfProvisioner{
|
ProvisionerStore: packersdk.MapOfProvisioner{
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
"file": func() (packersdk.Provisioner, error) { return &fileprovisioner.Provisioner{}, nil },
|
"file": func() (packersdk.Provisioner, error) { return &fileprovisioner.Provisioner{}, nil },
|
||||||
},
|
},
|
||||||
PostProcessorStore: packer.MapOfPostProcessor{},
|
PostProcessorStore: packersdk.MapOfPostProcessor{},
|
||||||
}
|
}
|
||||||
return &packer.CoreConfig{
|
return &packer.CoreConfig{
|
||||||
Components: components,
|
Components: components,
|
||||||
|
|
|
@ -1,5 +1,42 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
|
const (
|
||||||
|
// This is the key in configurations that is set to the name of the
|
||||||
|
// build.
|
||||||
|
BuildNameConfigKey = "packer_build_name"
|
||||||
|
|
||||||
|
// This is the key in the configuration that is set to the type
|
||||||
|
// of the builder that is run. This is useful for provisioners and
|
||||||
|
// such who want to make use of this.
|
||||||
|
BuilderTypeConfigKey = "packer_builder_type"
|
||||||
|
|
||||||
|
// this is the key in the configuration that is set to the version of the
|
||||||
|
// Packer Core. This can be used by plugins to set user agents, etc, without
|
||||||
|
// having to import the Core to find out the Packer version.
|
||||||
|
CoreVersionConfigKey = "packer_core_version"
|
||||||
|
|
||||||
|
// This is the key in configurations that is set to "true" when Packer
|
||||||
|
// debugging is enabled.
|
||||||
|
DebugConfigKey = "packer_debug"
|
||||||
|
|
||||||
|
// This is the key in configurations that is set to "true" when Packer
|
||||||
|
// force build is enabled.
|
||||||
|
ForceConfigKey = "packer_force"
|
||||||
|
|
||||||
|
// This key determines what to do when a normal multistep step fails
|
||||||
|
// - "cleanup" - run cleanup steps
|
||||||
|
// - "abort" - exit without cleanup
|
||||||
|
// - "ask" - ask the user
|
||||||
|
OnErrorConfigKey = "packer_on_error"
|
||||||
|
|
||||||
|
// TemplatePathKey is the path to the template that configured this build
|
||||||
|
TemplatePathKey = "packer_template_path"
|
||||||
|
|
||||||
|
// This key contains a map[string]string of the user variables for
|
||||||
|
// template processing.
|
||||||
|
UserVariablesConfigKey = "packer_user_variables"
|
||||||
|
)
|
||||||
|
|
||||||
// PackerConfig is a struct that contains the configuration keys that
|
// PackerConfig is a struct that contains the configuration keys that
|
||||||
// are sent by packer, properly tagged already so mapstructure can load
|
// are sent by packer, properly tagged already so mapstructure can load
|
||||||
// them. Embed this structure into your configuration class to get access to
|
// them. Embed this structure into your configuration class to get access to
|
||||||
|
|
|
@ -2,18 +2,16 @@ package packer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MapOfProvisioner map[string]func() (packersdk.Provisioner, error)
|
type MapOfProvisioner map[string]func() (Provisioner, error)
|
||||||
|
|
||||||
func (mop MapOfProvisioner) Has(provisioner string) bool {
|
func (mop MapOfProvisioner) Has(provisioner string) bool {
|
||||||
_, res := mop[provisioner]
|
_, res := mop[provisioner]
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mop MapOfProvisioner) Start(provisioner string) (packersdk.Provisioner, error) {
|
func (mop MapOfProvisioner) Start(provisioner string) (Provisioner, error) {
|
||||||
p, found := mop[provisioner]
|
p, found := mop[provisioner]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("Unknown provisioner %s", provisioner)
|
return nil, fmt.Errorf("Unknown provisioner %s", provisioner)
|
||||||
|
@ -29,14 +27,14 @@ func (mop MapOfProvisioner) List() []string {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
type MapOfPostProcessor map[string]func() (packersdk.PostProcessor, error)
|
type MapOfPostProcessor map[string]func() (PostProcessor, error)
|
||||||
|
|
||||||
func (mopp MapOfPostProcessor) Has(postProcessor string) bool {
|
func (mopp MapOfPostProcessor) Has(postProcessor string) bool {
|
||||||
_, res := mopp[postProcessor]
|
_, res := mopp[postProcessor]
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mopp MapOfPostProcessor) Start(postProcessor string) (packersdk.PostProcessor, error) {
|
func (mopp MapOfPostProcessor) Start(postProcessor string) (PostProcessor, error) {
|
||||||
p, found := mopp[postProcessor]
|
p, found := mopp[postProcessor]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("Unknown post-processor %s", postProcessor)
|
return nil, fmt.Errorf("Unknown post-processor %s", postProcessor)
|
||||||
|
@ -52,14 +50,14 @@ func (mopp MapOfPostProcessor) List() []string {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
type MapOfBuilder map[string]func() (packersdk.Builder, error)
|
type MapOfBuilder map[string]func() (Builder, error)
|
||||||
|
|
||||||
func (mob MapOfBuilder) Has(builder string) bool {
|
func (mob MapOfBuilder) Has(builder string) bool {
|
||||||
_, res := mob[builder]
|
_, res := mob[builder]
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mob MapOfBuilder) Start(builder string) (packersdk.Builder, error) {
|
func (mob MapOfBuilder) Start(builder string) (Builder, error) {
|
||||||
d, found := mob[builder]
|
d, found := mob[builder]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("Unknown builder %s", builder)
|
return nil, fmt.Errorf("Unknown builder %s", builder)
|
|
@ -1,47 +1,18 @@
|
||||||
package packer
|
package packer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"io/ioutil"
|
||||||
"strings"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestUi is a UI that only outputs unformatted output to the given writer.
|
func TestUi(t *testing.T) Ui {
|
||||||
type TestUi struct {
|
var buf bytes.Buffer
|
||||||
Writer io.Writer
|
return &BasicUi{
|
||||||
}
|
Reader: &buf,
|
||||||
|
Writer: ioutil.Discard,
|
||||||
var _ Ui = new(TestUi)
|
ErrorWriter: ioutil.Discard,
|
||||||
|
|
||||||
func (u *TestUi) Ask(query string) (string, error) {
|
|
||||||
return "", errors.New("Test UI can't ask")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *TestUi) Say(message string) {
|
|
||||||
log.Printf(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *TestUi) Message(message string) {
|
|
||||||
log.Printf(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *TestUi) Error(message string) {
|
|
||||||
log.Printf(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *TestUi) Machine(message string, args ...string) {
|
|
||||||
log.Printf("%s, %s", message, strings.Join(args, ", "))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *TestUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser) {
|
|
||||||
return &readCloser{
|
|
||||||
read: func(p []byte) (int, error) {
|
|
||||||
return stream.Read(p)
|
|
||||||
},
|
|
||||||
close: func() error {
|
|
||||||
return stream.Close()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,48 +6,12 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata"
|
"github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata"
|
||||||
"github.com/hashicorp/packer/version"
|
"github.com/hashicorp/packer/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// This is the key in configurations that is set to the name of the
|
|
||||||
// build.
|
|
||||||
BuildNameConfigKey = "packer_build_name"
|
|
||||||
|
|
||||||
// This is the key in the configuration that is set to the type
|
|
||||||
// of the builder that is run. This is useful for provisioners and
|
|
||||||
// such who want to make use of this.
|
|
||||||
BuilderTypeConfigKey = "packer_builder_type"
|
|
||||||
|
|
||||||
// this is the key in the configuration that is set to the version of the
|
|
||||||
// Packer Core. This can be used by plugins to set user agents, etc, without
|
|
||||||
// having to import the Core to find out the Packer version.
|
|
||||||
CoreVersionConfigKey = "packer_core_version"
|
|
||||||
|
|
||||||
// This is the key in configurations that is set to "true" when Packer
|
|
||||||
// debugging is enabled.
|
|
||||||
DebugConfigKey = "packer_debug"
|
|
||||||
|
|
||||||
// This is the key in configurations that is set to "true" when Packer
|
|
||||||
// force build is enabled.
|
|
||||||
ForceConfigKey = "packer_force"
|
|
||||||
|
|
||||||
// This key determines what to do when a normal multistep step fails
|
|
||||||
// - "cleanup" - run cleanup steps
|
|
||||||
// - "abort" - exit without cleanup
|
|
||||||
// - "ask" - ask the user
|
|
||||||
OnErrorConfigKey = "packer_on_error"
|
|
||||||
|
|
||||||
// TemplatePathKey is the path to the template that configured this build
|
|
||||||
TemplatePathKey = "packer_template_path"
|
|
||||||
|
|
||||||
// This key contains a map[string]string of the user variables for
|
|
||||||
// template processing.
|
|
||||||
UserVariablesConfigKey = "packer_user_variables"
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Build represents a single job within Packer that is responsible for
|
// A Build represents a single job within Packer that is responsible for
|
||||||
// building some machine image artifact. Builds are meant to be parallelized.
|
// building some machine image artifact. Builds are meant to be parallelized.
|
||||||
type Build interface {
|
type Build interface {
|
||||||
|
@ -165,14 +129,14 @@ func (b *CoreBuild) Prepare() (warn []string, err error) {
|
||||||
b.prepareCalled = true
|
b.prepareCalled = true
|
||||||
|
|
||||||
packerConfig := map[string]interface{}{
|
packerConfig := map[string]interface{}{
|
||||||
BuildNameConfigKey: b.Type,
|
common.BuildNameConfigKey: b.Type,
|
||||||
BuilderTypeConfigKey: b.BuilderType,
|
common.BuilderTypeConfigKey: b.BuilderType,
|
||||||
CoreVersionConfigKey: version.FormattedVersion(),
|
common.CoreVersionConfigKey: version.FormattedVersion(),
|
||||||
DebugConfigKey: b.debug,
|
common.DebugConfigKey: b.debug,
|
||||||
ForceConfigKey: b.force,
|
common.ForceConfigKey: b.force,
|
||||||
OnErrorConfigKey: b.onError,
|
common.OnErrorConfigKey: b.onError,
|
||||||
TemplatePathKey: b.TemplatePath,
|
common.TemplatePathKey: b.TemplatePath,
|
||||||
UserVariablesConfigKey: b.Variables,
|
common.UserVariablesConfigKey: b.Variables,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the builder
|
// Prepare the builder
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata"
|
"github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata"
|
||||||
"github.com/hashicorp/packer/version"
|
"github.com/hashicorp/packer/version"
|
||||||
|
@ -41,14 +42,14 @@ func testBuild() *CoreBuild {
|
||||||
|
|
||||||
func testDefaultPackerConfig() map[string]interface{} {
|
func testDefaultPackerConfig() map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
BuildNameConfigKey: "test",
|
common.BuildNameConfigKey: "test",
|
||||||
BuilderTypeConfigKey: "foo",
|
common.BuilderTypeConfigKey: "foo",
|
||||||
CoreVersionConfigKey: version.FormattedVersion(),
|
common.CoreVersionConfigKey: version.FormattedVersion(),
|
||||||
DebugConfigKey: false,
|
common.DebugConfigKey: false,
|
||||||
ForceConfigKey: false,
|
common.ForceConfigKey: false,
|
||||||
OnErrorConfigKey: "cleanup",
|
common.OnErrorConfigKey: "cleanup",
|
||||||
TemplatePathKey: "",
|
common.TemplatePathKey: "",
|
||||||
UserVariablesConfigKey: make(map[string]string),
|
common.UserVariablesConfigKey: make(map[string]string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestBuild_Name(t *testing.T) {
|
func TestBuild_Name(t *testing.T) {
|
||||||
|
@ -144,7 +145,7 @@ func TestBuildPrepare_BuilderWarnings(t *testing.T) {
|
||||||
|
|
||||||
func TestBuild_Prepare_Debug(t *testing.T) {
|
func TestBuild_Prepare_Debug(t *testing.T) {
|
||||||
packerConfig := testDefaultPackerConfig()
|
packerConfig := testDefaultPackerConfig()
|
||||||
packerConfig[DebugConfigKey] = true
|
packerConfig[common.DebugConfigKey] = true
|
||||||
|
|
||||||
build := testBuild()
|
build := testBuild()
|
||||||
builder := build.Builder.(*MockBuilder)
|
builder := build.Builder.(*MockBuilder)
|
||||||
|
@ -170,7 +171,7 @@ func TestBuild_Prepare_Debug(t *testing.T) {
|
||||||
|
|
||||||
func TestBuildPrepare_variables_default(t *testing.T) {
|
func TestBuildPrepare_variables_default(t *testing.T) {
|
||||||
packerConfig := testDefaultPackerConfig()
|
packerConfig := testDefaultPackerConfig()
|
||||||
packerConfig[UserVariablesConfigKey] = map[string]string{
|
packerConfig[common.UserVariablesConfigKey] = map[string]string{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,7 @@ func TestCoreBuild_provRetry(t *testing.T) {
|
||||||
b := TestBuilder(t, config, "test")
|
b := TestBuilder(t, config, "test")
|
||||||
pString := new(MockProvisioner)
|
pString := new(MockProvisioner)
|
||||||
pInt := new(MockProvisioner)
|
pInt := new(MockProvisioner)
|
||||||
config.Components.ProvisionerStore = MapOfProvisioner{
|
config.Components.ProvisionerStore = packersdk.MapOfProvisioner{
|
||||||
"test-string": func() (packersdk.Provisioner, error) { return pString, nil },
|
"test-string": func() (packersdk.Provisioner, error) { return pString, nil },
|
||||||
// backwards compatibility
|
// backwards compatibility
|
||||||
"test-integer": func() (packersdk.Provisioner, error) { return pInt, nil },
|
"test-integer": func() (packersdk.Provisioner, error) { return pInt, nil },
|
||||||
|
|
|
@ -20,12 +20,12 @@ const PACKERSPACE = "-PACKERSPACE-"
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PluginMinPort int
|
PluginMinPort int
|
||||||
PluginMaxPort int
|
PluginMaxPort int
|
||||||
builders packer.MapOfBuilder
|
builders packersdk.MapOfBuilder
|
||||||
provisioners packer.MapOfProvisioner
|
provisioners packersdk.MapOfProvisioner
|
||||||
postProcessors packer.MapOfPostProcessor
|
postProcessors packersdk.MapOfPostProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) GetPlugins() (packer.MapOfBuilder, packer.MapOfProvisioner, packer.MapOfPostProcessor) {
|
func (c *Config) GetPlugins() (packersdk.MapOfBuilder, packersdk.MapOfProvisioner, packersdk.MapOfPostProcessor) {
|
||||||
return c.builders, c.provisioners, c.postProcessors
|
return c.builders, c.provisioners, c.postProcessors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ func (c *Config) GetPlugins() (packer.MapOfBuilder, packer.MapOfProvisioner, pac
|
||||||
// CWD has the highest priority.
|
// CWD has the highest priority.
|
||||||
func (c *Config) Discover() error {
|
func (c *Config) Discover() error {
|
||||||
if c.builders == nil {
|
if c.builders == nil {
|
||||||
c.builders = packer.MapOfBuilder{}
|
c.builders = packersdk.MapOfBuilder{}
|
||||||
}
|
}
|
||||||
if c.provisioners == nil {
|
if c.provisioners == nil {
|
||||||
c.provisioners = packer.MapOfProvisioner{}
|
c.provisioners = packersdk.MapOfProvisioner{}
|
||||||
}
|
}
|
||||||
if c.postProcessors == nil {
|
if c.postProcessors == nil {
|
||||||
c.postProcessors = packer.MapOfPostProcessor{}
|
c.postProcessors = packersdk.MapOfPostProcessor{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are already inside a plugin process we should not need to
|
// If we are already inside a plugin process we should not need to
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func TestCoreConfig(t *testing.T) *CoreConfig {
|
func TestCoreConfig(t *testing.T) *CoreConfig {
|
||||||
// Create some test components
|
// Create some test components
|
||||||
components := ComponentFinder{
|
components := ComponentFinder{
|
||||||
BuilderStore: MapOfBuilder{
|
BuilderStore: packersdk.MapOfBuilder{
|
||||||
"test": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
|
"test": func() (packersdk.Builder, error) { return &MockBuilder{}, nil },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func TestUi(t *testing.T) packersdk.Ui {
|
||||||
func TestBuilder(t *testing.T, c *CoreConfig, n string) *MockBuilder {
|
func TestBuilder(t *testing.T, c *CoreConfig, n string) *MockBuilder {
|
||||||
var b MockBuilder
|
var b MockBuilder
|
||||||
|
|
||||||
c.Components.BuilderStore = MapOfBuilder{
|
c.Components.BuilderStore = packersdk.MapOfBuilder{
|
||||||
n: func() (packersdk.Builder, error) { return &b, nil },
|
n: func() (packersdk.Builder, error) { return &b, nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func TestBuilder(t *testing.T, c *CoreConfig, n string) *MockBuilder {
|
||||||
func TestProvisioner(t *testing.T, c *CoreConfig, n string) *MockProvisioner {
|
func TestProvisioner(t *testing.T, c *CoreConfig, n string) *MockProvisioner {
|
||||||
var b MockProvisioner
|
var b MockProvisioner
|
||||||
|
|
||||||
c.Components.ProvisionerStore = MapOfProvisioner{
|
c.Components.ProvisionerStore = packersdk.MapOfProvisioner{
|
||||||
n: func() (packersdk.Provisioner, error) { return &b, nil },
|
n: func() (packersdk.Provisioner, error) { return &b, nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func TestProvisioner(t *testing.T, c *CoreConfig, n string) *MockProvisioner {
|
||||||
func TestPostProcessor(t *testing.T, c *CoreConfig, n string) *MockPostProcessor {
|
func TestPostProcessor(t *testing.T, c *CoreConfig, n string) *MockPostProcessor {
|
||||||
var b MockPostProcessor
|
var b MockPostProcessor
|
||||||
|
|
||||||
c.Components.PostProcessorStore = MapOfPostProcessor{
|
c.Components.PostProcessorStore = packersdk.MapOfPostProcessor{
|
||||||
n: func() (packersdk.PostProcessor, error) { return &b, nil },
|
n: func() (packersdk.PostProcessor, error) { return &b, nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/file"
|
"github.com/hashicorp/packer/builder/file"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template"
|
||||||
)
|
)
|
||||||
|
@ -47,7 +46,7 @@ func TestChecksumSHA1(t *testing.T) {
|
||||||
|
|
||||||
func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) {
|
func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) {
|
||||||
// Create fake UI and Cache
|
// Create fake UI and Cache
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
// Create config for file builder
|
// Create config for file builder
|
||||||
const fileConfig = `{"builders":[{"type":"file","target":"package.txt","content":"Hello world!"}]}`
|
const fileConfig = `{"builders":[{"type":"file","target":"package.txt","content":"Hello world!"}]}`
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/builder/file"
|
"github.com/hashicorp/packer/builder/file"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template"
|
||||||
)
|
)
|
||||||
|
@ -187,7 +186,7 @@ func TestCompressInterpolation(t *testing.T) {
|
||||||
|
|
||||||
func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) {
|
func setup(t *testing.T) (packersdk.Ui, packersdk.Artifact, error) {
|
||||||
// Create fake UI and Cache
|
// Create fake UI and Cache
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
// Create config for file builder
|
// Create config for file builder
|
||||||
const fileConfig = `{"builders":[{"type":"file","target":"package.txt","content":"Hello world!"}]}`
|
const fileConfig = `{"builders":[{"type":"file","target":"package.txt","content":"Hello world!"}]}`
|
||||||
|
|
|
@ -329,7 +329,7 @@ func testProvisionerProvisionDockerWithPlaybookFiles(t *testing.T, templateStrin
|
||||||
t.Skip("This test is only run with PACKER_ACC=1")
|
t.Skip("This test is only run with PACKER_ACC=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := packer.TestUi(t)
|
ui := packersdk.TestUi(t)
|
||||||
|
|
||||||
tpl, err := template.Parse(strings.NewReader(templateString))
|
tpl, err := template.Parse(strings.NewReader(templateString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ func TestProvisionerPrepare_json(t *testing.T) {
|
||||||
"foo": "{{ user `foo` }}",
|
"foo": "{{ user `foo` }}",
|
||||||
}
|
}
|
||||||
|
|
||||||
config[packer.UserVariablesConfigKey] = map[string]string{
|
config[common.UserVariablesConfigKey] = map[string]string{
|
||||||
"foo": `"bar\baz"`,
|
"foo": `"bar\baz"`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/hashicorp/go-uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
"github.com/hashicorp/packer/helper/tests/acc"
|
"github.com/hashicorp/packer/helper/tests/acc"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/hashicorp/packer/provisioner/powershell"
|
"github.com/hashicorp/packer/provisioner/powershell"
|
||||||
windowsshellprovisioner "github.com/hashicorp/packer/provisioner/windows-shell"
|
windowsshellprovisioner "github.com/hashicorp/packer/provisioner/windows-shell"
|
||||||
|
@ -63,8 +62,8 @@ func (s *PowershellProvisionerAccTest) GetConfig() (string, error) {
|
||||||
return string(file), nil
|
return string(file), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PowershellProvisionerAccTest) GetProvisionerStore() packer.MapOfProvisioner {
|
func (s *PowershellProvisionerAccTest) GetProvisionerStore() packersdk.MapOfProvisioner {
|
||||||
return packer.MapOfProvisioner{
|
return packersdk.MapOfProvisioner{
|
||||||
TestProvisionerName: func() (packersdk.Provisioner, error) { return &powershell.Provisioner{}, nil },
|
TestProvisionerName: func() (packersdk.Provisioner, error) { return &powershell.Provisioner{}, nil },
|
||||||
"windows-shell": func() (packersdk.Provisioner, error) { return &windowsshellprovisioner.Provisioner{}, nil },
|
"windows-shell": func() (packersdk.Provisioner, error) { return &windowsshellprovisioner.Provisioner{}, nil },
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -89,7 +89,7 @@ func TestProvisionerPrepare_Config(t *testing.T) {
|
||||||
config := testConfig()
|
config := testConfig()
|
||||||
config["elevated_user"] = "{{user `user`}}"
|
config["elevated_user"] = "{{user `user`}}"
|
||||||
config["elevated_password"] = "{{user `password`}}"
|
config["elevated_password"] = "{{user `password`}}"
|
||||||
config[packer.UserVariablesConfigKey] = map[string]string{
|
config[common.UserVariablesConfigKey] = map[string]string{
|
||||||
"user": "myusername",
|
"user": "myusername",
|
||||||
"password": "mypassword",
|
"password": "mypassword",
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/hashicorp/packer/helper/tests/acc"
|
"github.com/hashicorp/packer/helper/tests/acc"
|
||||||
"github.com/hashicorp/packer/provisioner/shell"
|
"github.com/hashicorp/packer/provisioner/shell"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
|
@ -40,8 +39,8 @@ func (s *ShellLocalProvisionerAccTest) GetConfig() (string, error) {
|
||||||
return string(file), err
|
return string(file), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShellLocalProvisionerAccTest) GetProvisionerStore() packer.MapOfProvisioner {
|
func (s *ShellLocalProvisionerAccTest) GetProvisionerStore() packersdk.MapOfProvisioner {
|
||||||
return packer.MapOfProvisioner{
|
return packersdk.MapOfProvisioner{
|
||||||
"shell-local": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell-local": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/hashicorp/packer/provisioner/file"
|
"github.com/hashicorp/packer/provisioner/file"
|
||||||
"github.com/hashicorp/packer/provisioner/shell"
|
"github.com/hashicorp/packer/provisioner/shell"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
|
||||||
"github.com/hashicorp/go-uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
|
@ -43,8 +42,8 @@ func (s *ShellProvisionerAccTest) GetConfig() (string, error) {
|
||||||
return string(file), err
|
return string(file), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShellProvisionerAccTest) GetProvisionerStore() packer.MapOfProvisioner {
|
func (s *ShellProvisionerAccTest) GetProvisionerStore() packersdk.MapOfProvisioner {
|
||||||
return packer.MapOfProvisioner{
|
return packersdk.MapOfProvisioner{
|
||||||
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
"shell": func() (packersdk.Provisioner, error) { return &shell.Provisioner{}, nil },
|
||||||
"file": func() (packersdk.Provisioner, error) { return &file.Provisioner{}, nil },
|
"file": func() (packersdk.Provisioner, error) { return &file.Provisioner{}, nil },
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue