move multierror and multierrorappend into sdk

This commit is contained in:
Megan Marsh 2020-11-19 12:07:02 -08:00
parent 001886670d
commit c70870cb83
112 changed files with 908 additions and 898 deletions

View File

@ -7,7 +7,7 @@ import (
"strings"
"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
type Artifact struct {
@ -136,7 +136,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -68,10 +68,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AlicloudAccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.AlicloudImageConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AlicloudAccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.AlicloudImageConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs

View File

@ -5,7 +5,6 @@ import (
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -38,13 +37,13 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error {
ui.Say("Prevalidating source region and copied regions...")
var errs *packer.MultiError
var errs *packersdk.MultiError
if err := config.ValidateRegion(config.AlicloudRegion); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
for _, region := range config.AlicloudImageDestinationRegions {
if err := config.ValidateRegion(region); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}

View File

@ -261,19 +261,19 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors or warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...)
errs = packer.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...)
errs = packersdk.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
for _, mounts := range b.config.ChrootMounts {
if len(mounts) != 3 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("Each chroot_mounts entry should be three elements."))
break
}
@ -284,43 +284,43 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
warns = append(warns, "source_ami and source_ami_filter are unused when from_scratch is true")
}
if b.config.RootVolumeSize == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("root_volume_size is required with from_scratch."))
}
if len(b.config.PreMountCommands) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("pre_mount_commands is required with from_scratch."))
}
if b.config.AMIVirtType == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("ami_virtualization_type is required with from_scratch."))
}
if b.config.RootDeviceName == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("root_device_name is required with from_scratch."))
}
if len(b.config.AMIMappings) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("ami_block_device_mappings is required with from_scratch."))
}
} else {
if b.config.SourceAmi == "" && b.config.SourceAmiFilter.Empty() {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("source_ami or source_ami_filter is required."))
}
if len(b.config.AMIMappings) > 0 && b.config.RootDeviceName != "" {
if b.config.RootVolumeSize == 0 {
// Although, they can specify the device size in the block
// device mapping, it's easier to be specific here.
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("root_volume_size is required if ami_block_device_mappings is specified"))
}
warns = append(warns, "ami_block_device_mappings from source image will be completely overwritten")
} else if len(b.config.AMIMappings) > 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("If ami_block_device_mappings is specified, root_device_name must be specified"))
} else if b.config.RootDeviceName != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("If root_device_name is specified, ami_block_device_mappings must be specified"))
}
}
@ -332,7 +332,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
}
if !valid {
errs = packer.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`))
errs = packersdk.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -9,7 +9,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Artifact is an artifact implementation that contains built AMIs.
@ -103,7 +103,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -105,7 +104,7 @@ func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) m
var lock sync.Mutex
var wg sync.WaitGroup
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
wg.Add(len(s.Regions))
for _, region := range s.Regions {
var regKeyID string
@ -129,7 +128,7 @@ func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) m
amis[region] = id
snapshots[region] = snapshotIds
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}(region)
}

View File

@ -114,20 +114,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if b.config.IsSpotInstance() && (b.config.AMIENASupport.True() || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+
"you use an AMI that already has either SR-IOV or ENA enabled."))

View File

@ -113,20 +113,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...)
if b.config.AMIVirtType == "" {
errs = packer.MultiErrorAppend(errs, errors.New("ami_virtualization_type is required."))
errs = packersdk.MultiErrorAppend(errs, errors.New("ami_virtualization_type is required."))
}
foundRootVolume := false
@ -134,13 +134,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if launchDevice.DeviceName == b.config.RootDevice.SourceDeviceName {
foundRootVolume = true
if launchDevice.OmitFromArtifact {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot set \"omit_from_artifact\": \"true\" for the root volume."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot set \"omit_from_artifact\": \"true\" for the root volume."))
}
}
}
if !foundRootVolume {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
}
if b.config.RunConfig.SpotPriceAutoProduct != "" {
@ -162,7 +162,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
}
if !valid {
errs = packer.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`))
errs = packersdk.MultiErrorAppend(errs, errors.New(`The only valid ami_architecture values are "x86_64" and "arm64"`))
}
if errs != nil && len(errs.Errors) > 0 {
return nil, warns, errs

View File

@ -7,7 +7,7 @@ import (
"strings"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// map of region to list of volume IDs
@ -86,7 +86,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -122,26 +122,26 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
for _, d := range b.config.VolumeMappings {
if err := d.Prepare(&b.config.ctx); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("AMIMapping: %s", err.Error()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("AMIMapping: %s", err.Error()))
}
}
b.config.launchBlockDevices = b.config.VolumeMappings
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if b.config.IsSpotInstance() && ((b.config.AMIENASupport.True()) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+
"you use an AMI that already has either SR-IOV or ENA enabled."))

View File

@ -177,41 +177,41 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.AMIMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.LaunchMappings.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if b.config.AccountId == "" {
errs = packer.MultiErrorAppend(errs, errors.New("account_id is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("account_id is required"))
} else {
b.config.AccountId = strings.Replace(b.config.AccountId, "-", "", -1)
}
if b.config.S3Bucket == "" {
errs = packer.MultiErrorAppend(errs, errors.New("s3_bucket is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("s3_bucket is required"))
}
if b.config.X509CertPath == "" {
errs = packer.MultiErrorAppend(errs, errors.New("x509_cert_path is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("x509_cert_path is required"))
} else if _, err := os.Stat(b.config.X509CertPath); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("x509_cert_path points to bad file: %s", err))
}
if b.config.X509KeyPath == "" {
errs = packer.MultiErrorAppend(errs, errors.New("x509_key_path is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("x509_key_path is required"))
} else if _, err := os.Stat(b.config.X509KeyPath); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("x509_key_path points to bad file: %s", err))
}
if b.config.IsSpotInstance() && ((b.config.AMIENASupport.True()) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+
"you use an AMI that already has either SR-IOV or ENA enabled."))

View File

@ -31,6 +31,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -625,8 +626,8 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
}
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
assertRequiredParametersSet(c, errs)
assertTagProperties(c, errs)
@ -795,22 +796,22 @@ func provideDefaultValues(c *Config) {
c.ClientConfig.SetDefaultValues()
}
func assertTagProperties(c *Config, errs *packer.MultiError) {
func assertTagProperties(c *Config, errs *packersdk.MultiError) {
if len(c.AzureTags) > 15 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags)))
}
for k, v := range c.AzureTags {
if len(k) > 512 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k)))
}
if len(v) > 256 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", v, len(v)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", v, len(v)))
}
}
}
func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
func assertRequiredParametersSet(c *Config, errs *packersdk.MultiError) {
c.ClientConfig.Validate(errs)
/////////////////////////////////////////////
@ -823,13 +824,13 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
" that this value follows the full resource id format: "+
"/subscriptions/<SUBSCRIPTON_ID>/resourcegroups/<RESOURCE_GROUP>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<USER_ASSIGNED_IDENTITY_NAME>.\n"+
" Original error: %s", err)
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
} else {
if !strings.EqualFold(r.Provider, "Microsoft.ManagedIdentity") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource provider"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource provider"))
}
if !strings.EqualFold(r.ResourceType.String(), "userAssignedIdentities") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource type"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A valid user assigned managed identity resource id must have a correct resource type"))
}
}
}
@ -838,45 +839,45 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
/////////////////////////////////////////////
// Capture
if c.CaptureContainerName == "" && c.ManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified"))
}
if c.CaptureNamePrefix == "" && c.ManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified"))
}
if (c.CaptureNamePrefix != "" || c.CaptureContainerName != "") && (c.ManagedImageResourceGroupName != "" || c.ManagedImageName != "") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name."))
}
if c.CaptureContainerName != "" {
if !reCaptureContainerName.MatchString(c.CaptureContainerName) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String()))
}
if strings.HasSuffix(c.CaptureContainerName, "-") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'."))
}
if strings.Contains(c.CaptureContainerName, "--") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'."))
}
if c.CaptureNamePrefix == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified"))
}
if !reCaptureNamePrefix.MatchString(c.CaptureNamePrefix) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String()))
}
if strings.HasSuffix(c.CaptureNamePrefix, "-") || strings.HasSuffix(c.CaptureNamePrefix, ".") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period."))
}
}
if c.TempResourceGroupName != "" && c.BuildResourceGroupName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The settings temp_resource_group_name and build_resource_group_name cannot both be defined. Please define one or neither."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The settings temp_resource_group_name and build_resource_group_name cannot both be defined. Please define one or neither."))
}
/////////////////////////////////////////////
@ -897,55 +898,55 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
countSourceInputs := toInt(isImageUrl) + toInt(isCustomManagedImage) + toInt(isPlatformImage) + toInt(isSharedGallery)
if countSourceInputs > 1 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)"))
}
if isImageUrl && c.ManagedImageResourceGroupName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD."))
}
if c.SharedGallery.GalleryName != "" {
if c.SharedGallery.Subscription == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified"))
}
if c.SharedGallery.ResourceGroup == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified"))
}
if c.SharedGallery.ImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified"))
}
if c.CaptureContainerName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead."))
}
if c.CaptureNamePrefix != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead."))
}
} else if c.ImageUrl == "" && c.CustomManagedImageName == "" {
if c.ImagePublisher == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
}
if c.ImageOffer == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified"))
}
if c.ImageSku == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified"))
}
} else if c.ImageUrl == "" && c.ImagePublisher == "" {
if c.CustomManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_resource_group_name must be specified"))
}
if c.CustomManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified"))
}
if c.ManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed_image_resource_group_name must be specified"))
}
if c.ManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed_image_name must be specified"))
}
} else {
if c.ImagePublisher != "" || c.ImageOffer != "" || c.ImageSku != "" || c.ImageVersion != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified"))
}
}
@ -956,58 +957,58 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
}
if !xor((c.StorageAccount != "" || c.ResourceGroupName != ""), (c.ManagedImageName != "" || c.ManagedImageResourceGroupName != "")) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (storage_account and resource_group_name) or Managed Image (managed_image_resource_group_name and managed_image_name) output"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (storage_account and resource_group_name) or Managed Image (managed_image_resource_group_name and managed_image_name) output"))
}
if !xor(c.Location != "", c.BuildResourceGroupName != "") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a location to create the resource group in or an existing build_resource_group_name, but not both."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a location to create the resource group in or an existing build_resource_group_name, but not both."))
}
if c.ManagedImageName == "" && c.ManagedImageResourceGroupName == "" {
if c.StorageAccount == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A storage_account must be specified"))
}
if c.ResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified"))
}
}
if c.TempResourceGroupName != "" {
if ok, err := assertResourceGroupName(c.TempResourceGroupName, "temp_resource_group_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.BuildResourceGroupName != "" {
if ok, err := assertResourceGroupName(c.BuildResourceGroupName, "build_resource_group_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.ManagedImageResourceGroupName != "" {
if ok, err := assertResourceGroupName(c.ManagedImageResourceGroupName, "managed_image_resource_group_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.ManagedImageName != "" {
if ok, err := assertManagedImageName(c.ManagedImageName, "managed_image_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.ManagedImageName != "" && c.ManagedImageResourceGroupName != "" && c.SharedGalleryDestination.SigDestinationGalleryName != "" {
if c.SharedGalleryDestination.SigDestinationResourceGroup == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group must be specified for shared_image_gallery_destination"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A resource_group must be specified for shared_image_gallery_destination"))
}
if c.SharedGalleryDestination.SigDestinationImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_name must be specified for shared_image_gallery_destination"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_name must be specified for shared_image_gallery_destination"))
}
if c.SharedGalleryDestination.SigDestinationImageVersion == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_version must be specified for shared_image_gallery_destination"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_version must be specified for shared_image_gallery_destination"))
}
if len(c.SharedGalleryDestination.SigDestinationReplicationRegions) == 0 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A list of replication_regions must be specified for shared_image_gallery_destination"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A list of replication_regions must be specified for shared_image_gallery_destination"))
}
if c.SharedGalleryDestination.SigDestinationSubscription == "" {
c.SharedGalleryDestination.SigDestinationSubscription = c.ClientConfig.SubscriptionID
@ -1020,35 +1021,35 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
if c.ManagedImageOSDiskSnapshotName != "" {
if ok, err := assertManagedImageOSDiskSnapshotName(c.ManagedImageOSDiskSnapshotName, "managed_image_os_disk_snapshot_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.ManagedImageDataDiskSnapshotPrefix != "" {
if ok, err := assertManagedImageDataDiskSnapshotName(c.ManagedImageDataDiskSnapshotPrefix, "managed_image_data_disk_snapshot_prefix"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.CustomResourcePrefix != "" {
if ok, err := assertResourceNamePrefix(c.CustomResourcePrefix, "custom_resource_build_prefix"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.VirtualNetworkName == "" && c.VirtualNetworkResourceGroupName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name"))
}
if c.VirtualNetworkName == "" && c.VirtualNetworkSubnetName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name"))
}
if c.AllowedInboundIpAddresses != nil && len(c.AllowedInboundIpAddresses) >= 1 {
if c.VirtualNetworkName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_name is specified, allowed_inbound_ip_addresses cannot be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_name is specified, allowed_inbound_ip_addresses cannot be specified"))
} else {
if ok, err := assertAllowedInboundIpAddresses(c.AllowedInboundIpAddresses, "allowed_inbound_ip_addresses"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
}
@ -1057,7 +1058,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
// Plan Info
if c.PlanInfo.PlanName != "" || c.PlanInfo.PlanProduct != "" || c.PlanInfo.PlanPublisher != "" || c.PlanInfo.PlanPromotionCode != "" {
if c.PlanInfo.PlanName == "" || c.PlanInfo.PlanProduct == "" || c.PlanInfo.PlanPublisher == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("if either plan_name, plan_product, plan_publisher, or plan_promotion_code are defined then plan_name, plan_product, and plan_publisher must be defined"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("if either plan_name, plan_product, plan_publisher, or plan_promotion_code are defined then plan_name, plan_product, and plan_publisher must be defined"))
} else {
if c.AzureTags == nil {
c.AzureTags = make(map[string]string)
@ -1084,9 +1085,9 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
} else if strings.EqualFold(c.OSType, constants.Target_Windows) {
c.OSType = constants.Target_Windows
} else if c.OSType == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified"))
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType))
}
switch c.ManagedImageStorageAccountType {
@ -1095,7 +1096,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
case string(compute.StorageAccountTypesPremiumLRS):
c.managedImageStorageAccountType = compute.StorageAccountTypesPremiumLRS
default:
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType))
}
switch c.DiskCachingType {
@ -1106,7 +1107,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
case "", string(compute.CachingTypesReadWrite):
c.diskCachingType = compute.CachingTypesReadWrite
default:
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The disk_caching_type %q is invalid", c.DiskCachingType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The disk_caching_type %q is invalid", c.DiskCachingType))
}
}

View File

@ -174,7 +174,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
// Defaults
@ -222,7 +222,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
&b.config.ctx); err == nil {
b.config.TemporaryOSDiskID = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary disk id: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary disk id: %s", err))
}
}
@ -232,7 +232,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
&b.config.ctx); err == nil {
b.config.TemporaryOSDiskSnapshotID = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary snapshot id: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary snapshot id: %s", err))
}
}
@ -242,7 +242,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
&b.config.ctx); err == nil {
b.config.TemporaryDataDiskIDPrefix = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk id prefix: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk id prefix: %s", err))
}
}
@ -252,7 +252,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
&b.config.ctx); err == nil {
b.config.TemporaryDataDiskSnapshotIDPrefix = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk snapshot id prefix: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unable to render temporary data disk snapshot id prefix: %s", err))
}
}
@ -280,15 +280,15 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.FromScratch {
if b.config.Source != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("source cannot be specified when building from_scratch"))
}
if b.config.OSDiskSizeGB == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("os_disk_size_gb is required with from_scratch"))
}
if len(b.config.PreMountCommands) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("pre_mount_commands is required with from_scratch"))
}
} else {
@ -306,25 +306,25 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
log.Println("Source is a shared image ID:", b.config.Source)
b.config.sourceType = sourceSharedImage
} else {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("source: %q is not a valid platform image specifier, nor is it a disk resource ID", b.config.Source))
}
}
if err := checkDiskCacheType(b.config.OSDiskCacheType); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("os_disk_cache_type: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("os_disk_cache_type: %v", err))
}
if err := checkStorageAccountType(b.config.OSDiskStorageAccountType); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("os_disk_storage_account_type: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("os_disk_storage_account_type: %v", err))
}
if err := checkDiskCacheType(b.config.DataDiskCacheType); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("data_disk_cache_type: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("data_disk_cache_type: %v", err))
}
if err := checkStorageAccountType(b.config.DataDiskStorageAccountType); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("data_disk_storage_account_type: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("data_disk_storage_account_type: %v", err))
}
if b.config.ImageResourceID != "" {
@ -332,7 +332,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if err != nil ||
!strings.EqualFold(r.Provider, "Microsoft.Compute") ||
!strings.EqualFold(r.ResourceType, "images") {
errs = packer.MultiErrorAppend(fmt.Errorf(
errs = packersdk.MultiErrorAppend(fmt.Errorf(
"image_resource_id: %q is not a valid image resource id", b.config.ImageResourceID))
}
}
@ -340,7 +340,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if azcommon.StringsContains(md.Keys, "shared_image_destination") {
e, w := b.config.SharedImageGalleryDestination.Validate("shared_image_destination")
if len(e) > 0 {
errs = packer.MultiErrorAppend(errs, e...)
errs = packersdk.MultiErrorAppend(errs, e...)
}
if len(w) > 0 {
warns = append(warns, w...)
@ -348,11 +348,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if !azcommon.StringsContains(md.Keys, "shared_image_destination") && b.config.ImageResourceID == "" {
errs = packer.MultiErrorAppend(errs, errors.New("image_resource_id or shared_image_destination is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("image_resource_id or shared_image_destination is required"))
}
if err := checkHyperVGeneration(b.config.ImageHyperVGeneration); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("image_hyperv_generation: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("image_hyperv_generation: %v", err))
}
if errs != nil {

View File

@ -9,7 +9,7 @@ import (
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/packer/builder/azure/common/client"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Artifact is an artifact implementation that contains built Managed Images or Disks.
@ -96,7 +96,7 @@ func (a *Artifact) Destroy() error {
if len(errs) == 1 {
return errs[0]
} else {
return &packer.MultiError{Errors: errs}
return &packersdk.MultiError{Errors: errs}
}
}

View File

@ -11,7 +11,7 @@ import (
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
jwt "github.com/dgrijalva/jwt-go"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
// Config allows for various ways to authenticate Azure clients.
@ -120,7 +120,7 @@ func (c *Config) setCloudEnvironment() error {
return err
}
func (c Config) Validate(errs *packer.MultiError) {
func (c Config) Validate(errs *packersdk.MultiError) {
/////////////////////////////////////////////
// Authentication via OAUTH
@ -160,7 +160,7 @@ func (c Config) Validate(errs *packer.MultiError) {
// Service principal using certificate
if _, err := os.Stat(c.ClientCertPath); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_cert_path is not an accessible file: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_cert_path is not an accessible file: %v", err))
}
return
}
@ -176,20 +176,20 @@ func (c Config) Validate(errs *packer.MultiError) {
claims := jwt.StandardClaims{}
token, _, err := p.ParseUnverified(c.ClientJWT, &claims)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt is not a JWT: %v", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt is not a JWT: %v", err))
} else {
if claims.ExpiresAt < time.Now().Add(5*time.Minute).Unix() {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt will expire within 5 minutes, please use a JWT that is valid for at least 5 minutes"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt will expire within 5 minutes, please use a JWT that is valid for at least 5 minutes"))
}
if t, ok := token.Header["x5t"]; !ok || t == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("client_jwt is missing the x5t header value, which is required for bearer JWT client authentication to Azure"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("client_jwt is missing the x5t header value, which is required for bearer JWT client authentication to Azure"))
}
}
return
}
errs = packer.MultiErrorAppend(errs, fmt.Errorf("No valid set of authentication values specified:\n"+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("No valid set of authentication values specified:\n"+
" to use the Managed Identity of the current machine, do not specify any of the fields below\n"+
" to use interactive user authentication, specify only subscription_id\n"+
" to use an Azure Active Directory service principal, specify either:\n"+

View File

@ -14,7 +14,7 @@ import (
"github.com/Azure/go-autorest/autorest/azure"
jwt "github.com/dgrijalva/jwt-go"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func Test_ClientConfig_RequiredParametersSet(t *testing.T) {
@ -126,7 +126,7 @@ func Test_ClientConfig_RequiredParametersSet(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
errs := &packer.MultiError{}
errs := &packersdk.MultiError{}
tt.config.Validate(errs)
if (len(errs.Errors) != 0) != tt.wantErr {
t.Errorf("newConfig() error = %v, wantErr %v", errs, tt.wantErr)
@ -312,7 +312,7 @@ func Test_ClientConfig_CanUseDeviceCode(t *testing.T) {
}
func assertValid(t *testing.T, cfg Config) {
errs := &packer.MultiError{}
errs := &packersdk.MultiError{}
cfg.Validate(errs)
if len(errs.Errors) != 0 {
t.Fatal("Expected errs to be empty: ", errs)
@ -320,7 +320,7 @@ func assertValid(t *testing.T, cfg Config) {
}
func assertInvalid(t *testing.T, cfg Config) {
errs := &packer.MultiError{}
errs := &packersdk.MultiError{}
cfg.Validate(errs)
if len(errs.Errors) == 0 {
t.Fatal("Expected errs to be non-empty")

View File

@ -27,6 +27,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -424,8 +425,8 @@ func newConfig(raws ...interface{}) (*Config, []string, error) {
}
}
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
c.ClientConfig.Validate(errs)
@ -542,66 +543,66 @@ func provideDefaultValues(c *Config) {
}
}
func assertTagProperties(c *Config, errs *packer.MultiError) {
func assertTagProperties(c *Config, errs *packersdk.MultiError) {
if len(c.AzureTags) > 15 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a max of 15 tags are supported, but %d were provided", len(c.AzureTags)))
}
for k, v := range c.AzureTags {
if len(k) > 512 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 512 character limit", k, len(k)))
}
if len(*v) > 256 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", *v, len(*v)))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the tag name %q exceeds (%d) the 256 character limit", *v, len(*v)))
}
}
}
func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
func assertRequiredParametersSet(c *Config, errs *packersdk.MultiError) {
c.ClientConfig.Validate(errs)
/////////////////////////////////////////////
// Capture
if c.CaptureContainerName == "" && c.ManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name or managed_image_name must be specified"))
}
if c.CaptureNamePrefix == "" && c.ManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix or managed_image_resource_group_name must be specified"))
}
if (c.CaptureNamePrefix != "" || c.CaptureContainerName != "") && (c.ManagedImageResourceGroupName != "" || c.ManagedImageName != "") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Either a VHD or a managed image can be built, but not both. Please specify either capture_container_name and capture_name_prefix or managed_image_resource_group_name and managed_image_name."))
}
if c.CaptureContainerName != "" {
if !reCaptureContainerName.MatchString(c.CaptureContainerName) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must satisfy the regular expression %q.", reCaptureContainerName.String()))
}
if strings.HasSuffix(c.CaptureContainerName, "-") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not end with a hyphen, e.g. '-'."))
}
if strings.Contains(c.CaptureContainerName, "--") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_container_name must not contain consecutive hyphens, e.g. '--'."))
}
if c.CaptureNamePrefix == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must be specified"))
}
if !reCaptureNamePrefix.MatchString(c.CaptureNamePrefix) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must satisfy the regular expression %q.", reCaptureNamePrefix.String()))
}
if strings.HasSuffix(c.CaptureNamePrefix, "-") || strings.HasSuffix(c.CaptureNamePrefix, ".") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A capture_name_prefix must not end with a hyphen or period."))
}
}
if c.LabResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The settings lab_resource_group_name needs to be defined."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The settings lab_resource_group_name needs to be defined."))
}
/////////////////////////////////////////////
@ -622,75 +623,75 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
countSourceInputs := toInt(isImageUrl) + toInt(isCustomManagedImage) + toInt(isPlatformImage) + toInt(isSharedGallery)
if countSourceInputs > 1 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Specify either a VHD (image_url), Image Reference (image_publisher, image_offer, image_sku), a Managed Disk (custom_managed_disk_image_name, custom_managed_disk_resource_group_name), or a Shared Gallery Image (shared_image_gallery)"))
}
if isImageUrl && c.ManagedImageResourceGroupName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A managed image must be created from a managed image, it cannot be created from a VHD."))
}
if c.SharedGallery.GalleryName != "" {
if c.SharedGallery.Subscription == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.subscription must be specified"))
}
if c.SharedGallery.ResourceGroup == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.resource_group must be specified"))
}
if c.SharedGallery.ImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A shared_image_gallery.image_name must be specified"))
}
if c.CaptureContainerName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_container_name] is not supported when using Shared Image Gallery as source. Use managed_image_resource_group_name instead."))
}
if c.CaptureNamePrefix != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("VHD Target [capture_name_prefix] is not supported when using Shared Image Gallery as source. Use managed_image_name instead."))
}
} else if c.ImageUrl == "" && c.CustomManagedImageName == "" {
if c.ImagePublisher == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_publisher must be specified"))
}
if c.ImageOffer == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_offer must be specified"))
}
if c.ImageSku == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_sku must be specified"))
}
} else if c.ImageUrl == "" && c.ImagePublisher == "" {
if c.CustomManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An custom_managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An custom_managed_image_resource_group_name must be specified"))
}
if c.CustomManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("A custom_managed_image_name must be specified"))
}
if c.ManagedImageResourceGroupName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An managed_image_resource_group_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An managed_image_resource_group_name must be specified"))
}
if c.ManagedImageName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An managed_image_name must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An managed_image_name must be specified"))
}
} else {
if c.ImagePublisher != "" || c.ImageOffer != "" || c.ImageSku != "" || c.ImageVersion != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An image_url must not be specified if image_publisher, image_offer, image_sku, or image_version is specified"))
}
}
if c.ManagedImageResourceGroupName != "" {
if ok, err := assertResourceGroupName(c.ManagedImageResourceGroupName, "managed_image_resource_group_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.ManagedImageName != "" {
if ok, err := assertManagedImageName(c.ManagedImageName, "managed_image_name"); !ok {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.LabVirtualNetworkName == "" && c.LabResourceGroupName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("If lab_resource_group_name is specified, so must lab_virtual_network_name"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If lab_resource_group_name is specified, so must lab_virtual_network_name"))
}
if c.LabVirtualNetworkName == "" && c.LabSubnetName != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must lab_virtual_network_name"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must lab_virtual_network_name"))
}
/////////////////////////////////////////////
@ -707,9 +708,9 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
} else if strings.EqualFold(c.OSType, constants.Target_Windows) {
c.OSType = constants.Target_Windows
} else if c.OSType == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("An os_type must be specified"))
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The os_type %q is invalid", c.OSType))
}
switch c.ManagedImageStorageAccountType {
@ -718,7 +719,7 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
case string(compute.StorageAccountTypesPremiumLRS):
c.managedImageStorageAccountType = compute.StorageAccountTypesPremiumLRS
default:
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType))
}
// Errs check to make the linter happy.
if errs != nil {

View File

@ -10,9 +10,9 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -182,7 +182,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
return err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
// Set some defaults.
if c.APIURL == "" {
@ -219,7 +219,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
if c.TemplateName == "" {
name, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Unable to parse template name: %s ", err))
}
@ -240,71 +240,71 @@ func (c *Config) Prepare(raws ...interface{}) error {
// Process required parameters.
if c.APIURL == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a api_url must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a api_url must be specified"))
}
if c.APIKey == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a api_key must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a api_key must be specified"))
}
if c.SecretKey == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a secret_key must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a secret_key must be specified"))
}
if c.Network == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a network must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a network must be specified"))
}
if c.CreateSecurityGroup && !c.Expunge {
errs = packer.MultiErrorAppend(errs, errors.New("auto creating a temporary security group requires expunge"))
errs = packersdk.MultiErrorAppend(errs, errors.New("auto creating a temporary security group requires expunge"))
}
if c.ServiceOffering == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a service_offering must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a service_offering must be specified"))
}
if c.SourceISO == "" && c.SourceTemplate == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("either source_iso or source_template must be specified"))
}
if c.SourceISO != "" && c.SourceTemplate != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("only one of source_iso or source_template can be specified"))
}
if c.SourceISO != "" && c.DiskOffering == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a disk_offering must be specified when using source_iso"))
}
if c.SourceISO != "" && c.Hypervisor == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a hypervisor must be specified when using source_iso"))
}
if c.TemplateOS == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a template_os must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a template_os must be specified"))
}
if c.UserData != "" && c.UserDataFile != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("only one of user_data or user_data_file can be specified"))
}
if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
}
}
if c.Zone == "" {
errs = packer.MultiErrorAppend(errs, errors.New("a zone must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("a zone must be specified"))
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
// Check for errors and return if we have any.

View File

@ -6,7 +6,6 @@ import (
"io/ioutil"
"regexp"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/xanzy/go-cloudstack/cloudstack"
@ -22,20 +21,20 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
ui.Say("Preparing config...")
var err error
var errs *packer.MultiError
var errs *packersdk.MultiError
// First get the project and zone UUID's so we can use them in other calls when needed.
if config.Project != "" && !isUUID(config.Project) {
config.Project, _, err = client.Project.GetProjectID(config.Project)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"project", config.Project, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"project", config.Project, err})
}
}
if config.UserDataFile != "" {
userdata, err := ioutil.ReadFile(config.UserDataFile)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("problem reading user data file: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("problem reading user data file: %s", err))
}
config.UserData = string(userdata)
}
@ -43,7 +42,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if !isUUID(config.Zone) {
config.Zone, _, err = client.Zone.GetZoneID(config.Zone)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"zone", config.Zone, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"zone", config.Zone, err})
}
}
@ -51,7 +50,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if config.DiskOffering != "" && !isUUID(config.DiskOffering) {
config.DiskOffering, _, err = client.DiskOffering.GetDiskOfferingID(config.DiskOffering)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"disk offering", config.DiskOffering, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"disk offering", config.DiskOffering, err})
}
}
@ -59,7 +58,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if isUUID(config.PublicIPAddress) {
ip, _, err := client.Address.GetPublicIpAddressByID(config.PublicIPAddress)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed to retrieve IP address: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed to retrieve IP address: %s", err))
}
state.Put("ipaddress", ip.Ipaddress)
} else {
@ -75,10 +74,10 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
ipAddrs, err := client.Address.ListPublicIpAddresses(p)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, err})
}
if err == nil && ipAddrs.Count != 1 {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, ipAddrs})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, ipAddrs})
}
if err == nil && ipAddrs.Count == 1 {
config.PublicIPAddress = ipAddrs.PublicIpAddresses[0].Id
@ -89,7 +88,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if !isUUID(config.Network) {
config.Network, _, err = client.Network.GetNetworkID(config.Network, cloudstack.WithProject(config.Project))
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"network", config.Network, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"network", config.Network, err})
}
}
@ -99,7 +98,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if !isUUID(config.SecurityGroups[i]) {
config.SecurityGroups[i], _, err = client.SecurityGroup.GetSecurityGroupID(config.SecurityGroups[i], cloudstack.WithProject(config.Project))
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"network", config.SecurityGroups[i], err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"network", config.SecurityGroups[i], err})
}
}
}
@ -108,7 +107,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
if !isUUID(config.ServiceOffering) {
config.ServiceOffering, _, err = client.ServiceOffering.GetServiceOfferingID(config.ServiceOffering)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"service offering", config.ServiceOffering, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"service offering", config.ServiceOffering, err})
}
}
@ -118,7 +117,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
} else {
isoID, _, err := client.ISO.GetIsoID(config.SourceISO, "executable", config.Zone)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err})
}
state.Put("source", isoID)
}
@ -130,7 +129,7 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
} else {
templateID, _, err := client.Template.GetTemplateID(config.SourceTemplate, "executable", config.Zone)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err})
}
state.Put("source", templateID)
}
@ -142,19 +141,19 @@ func (s *stepPrepareConfig) Run(ctx context.Context, state multistep.StateBag) m
types, err := client.GuestOS.ListOsTypes(p)
if err != nil {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, err})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, err})
}
if err == nil && types.Count != 1 {
errs = packer.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, types})
errs = packersdk.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, types})
}
if err == nil && types.Count == 1 {
config.TemplateOS = types.OsTypes[0].Id
}
}
// This is needed because nil is not always nil. When returning *packer.MultiError(nil)
// This is needed because nil is not always nil. When returning *packersdk.MultiError(nil)
// as an error interface, that interface will no longer be equal to nil but it will be
// an interface with type *packer.MultiError and value nil which is different then a
// an interface with type *packersdk.MultiError and value nil which is different then a
// nil interface.
if errs != nil && len(errs.Errors) > 0 {
state.Put("error", errs)

View File

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -148,38 +149,38 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.SnapshotTimeout = 60 * time.Minute
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.APIToken == "" {
// Required configurations that will display errors if not set
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("api_token for auth must be specified"))
}
if c.Region == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("region is required"))
}
if c.Size == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("size is required"))
}
if c.Image == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("image is required"))
}
if c.UserData != "" && c.UserDataFile != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("only one of user_data or user_data_file can be specified"))
} else if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New(fmt.Sprintf("user_data_file not found: %s", c.UserDataFile)))
}
}
@ -191,7 +192,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
for _, t := range c.Tags {
if !tagRe.MatchString(t) {
errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t)))
errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf("invalid tag: %s", t)))
}
}

View File

@ -8,8 +8,8 @@ import (
"os"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/mitchellh/mapstructure"
@ -169,25 +169,25 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.Image == "" {
errs = packer.MultiErrorAppend(errs, errImageNotSpecified)
errs = packersdk.MultiErrorAppend(errs, errImageNotSpecified)
}
if (c.ExportPath != "" && c.Commit) || (c.ExportPath != "" && c.Discard) || (c.Commit && c.Discard) {
errs = packer.MultiErrorAppend(errs, errArtifactUseConflict)
errs = packersdk.MultiErrorAppend(errs, errArtifactUseConflict)
}
if c.ExportPath == "" && !c.Commit && !c.Discard {
errs = packer.MultiErrorAppend(errs, errArtifactNotUsed)
errs = packersdk.MultiErrorAppend(errs, errArtifactNotUsed)
}
if c.ExportPath != "" {
if fi, err := os.Stat(c.ExportPath); err == nil && fi.IsDir() {
errs = packer.MultiErrorAppend(errs, errExportPathNotFile)
errs = packersdk.MultiErrorAppend(errs, errExportPathNotFile)
}
}
@ -200,7 +200,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.EcrLogin && c.LoginServer == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("ECR login requires login server to be provided."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("ECR login requires login server to be provided."))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -5,8 +5,8 @@ package file
import (
"fmt"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -35,10 +35,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return warnings, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.Target == "" {
errs = packer.MultiErrorAppend(errs, ErrTargetRequired)
errs = packersdk.MultiErrorAppend(errs, ErrTargetRequired)
}
if c.Content == "" && c.Source == "" {
@ -46,7 +46,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.Content != "" && c.Source != "" {
errs = packer.MultiErrorAppend(errs, ErrContentSourceConflict)
errs = packersdk.MultiErrorAppend(errs, ErrContentSourceConflict)
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -12,8 +12,8 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -310,7 +310,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
// Set defaults.
if c.Network == "" && c.Subnetwork == "" {
@ -333,7 +333,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// monitoring relies on data gathered by Measured Boot.
if !c.EnableVtpm {
if c.EnableIntegrityMonitoring {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("You cannot enable Integrity Monitoring when vTPM is disabled."))
}
}
@ -343,7 +343,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.OnHostMaintenance == "MIGRATE" && c.Preemptible {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("on_host_maintenance must be TERMINATE when using preemptible instances."))
}
// Setting OnHostMaintenance Correct Defaults
@ -359,14 +359,14 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Make sure user sets a valid value for on_host_maintenance option
if !(c.OnHostMaintenance == "MIGRATE" || c.OnHostMaintenance == "TERMINATE") {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("on_host_maintenance must be one of MIGRATE or TERMINATE."))
}
if c.ImageName == "" {
img, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Unable to parse image name: %s ", err))
} else {
c.ImageName = img
@ -377,27 +377,27 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
imageErrorText := "Invalid image %s %q: The first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash"
if len(c.ImageName) > 63 {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Invalid image name: Must not be longer than 63 characters"))
}
if !validImageName.MatchString(c.ImageName) {
errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "name", c.ImageName)))
errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "name", c.ImageName)))
}
if len(c.ImageFamily) > 63 {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Invalid image family: Must not be longer than 63 characters"))
}
if c.ImageFamily != "" {
if !validImageName.MatchString(c.ImageFamily) {
errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "family", c.ImageFamily)))
errs = packersdk.MultiErrorAppend(errs, errors.New(fmt.Sprintf(imageErrorText, "family", c.ImageFamily)))
}
}
if len(c.ImageStorageLocations) > 1 {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Invalid image storage locations: Must not have more than 1 region"))
}
@ -419,7 +419,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Set up communicator
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
// set defaults for IAP
@ -449,7 +449,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.IAPConfig.IAP {
if !SupportsIAPTunnel(&c.Comm) {
err := fmt.Errorf("Error: IAP tunnel is not implemented for %s communicator", c.Comm.Type)
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
// These configuration values are copied early to the generic host parameter when configuring
// StepConnect. As such they must be set now. Ideally we would handle this as part of
@ -462,7 +462,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Process required parameters.
if c.ProjectId == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a project_id must be specified"))
}
@ -475,12 +475,12 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.SourceImage == "" && c.SourceImageFamily == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a source_image or source_image_family must be specified"))
}
if c.Zone == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a zone must be specified"))
}
if c.Region == "" && len(c.Zone) > 2 {
@ -492,40 +492,40 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Authenticating via an account file
if c.AccountFile != "" {
if c.VaultGCPOauthEngine != "" && c.ImpersonateServiceAccount != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot "+
"specify impersonate_service_account, account_file and vault_gcp_oauth_engine at the same time"))
}
cfg, err := ProcessAccountFile(c.AccountFile)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
c.account = cfg
}
if c.OmitExternalIP && c.Address != "" {
errs = packer.MultiErrorAppend(fmt.Errorf("you can not specify an external address when 'omit_external_ip' is true"))
errs = packersdk.MultiErrorAppend(fmt.Errorf("you can not specify an external address when 'omit_external_ip' is true"))
}
if c.OmitExternalIP && !c.UseInternalIP {
errs = packer.MultiErrorAppend(fmt.Errorf("'use_internal_ip' must be true if 'omit_external_ip' is true"))
errs = packersdk.MultiErrorAppend(fmt.Errorf("'use_internal_ip' must be true if 'omit_external_ip' is true"))
}
if c.AcceleratorCount > 0 && len(c.AcceleratorType) == 0 {
errs = packer.MultiErrorAppend(fmt.Errorf("'accelerator_type' must be set when 'accelerator_count' is more than 0"))
errs = packersdk.MultiErrorAppend(fmt.Errorf("'accelerator_type' must be set when 'accelerator_count' is more than 0"))
}
if c.AcceleratorCount > 0 && c.OnHostMaintenance != "TERMINATE" {
errs = packer.MultiErrorAppend(fmt.Errorf("'on_host_maintenance' must be set to 'TERMINATE' when 'accelerator_count' is more than 0"))
errs = packersdk.MultiErrorAppend(fmt.Errorf("'on_host_maintenance' must be set to 'TERMINATE' when 'accelerator_count' is more than 0"))
}
// If DisableDefaultServiceAccount is provided, don't allow a value for ServiceAccountEmail
if c.DisableDefaultServiceAccount && c.ServiceAccountEmail != "" {
errs = packer.MultiErrorAppend(fmt.Errorf("you may not specify a 'service_account_email' when 'disable_default_service_account' is true"))
errs = packersdk.MultiErrorAppend(fmt.Errorf("you may not specify a 'service_account_email' when 'disable_default_service_account' is true"))
}
if c.StartupScriptFile != "" {
if _, err := os.Stat(c.StartupScriptFile); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("startup_script_file: %v", err))
}

View File

@ -18,7 +18,6 @@ import (
oslogin "google.golang.org/api/oslogin/v1"
"github.com/hashicorp/packer/builder/googlecompute/version"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/retry"
"github.com/hashicorp/packer/packer-plugin-sdk/useragent"
@ -263,7 +262,7 @@ func (d *driverGCE) GetImageFromProjects(projects []string, name string, fromFam
for _, project := range projects {
image, err := d.GetImageFromProject(project, name, fromFamily)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if image != nil {
return image, nil
@ -676,7 +675,7 @@ func (d *driverGCE) refreshGlobalOp(op *compute.Operation) stateRefreshFunc {
if newOp.Status == "DONE" {
if newOp.Error != nil {
for _, e := range newOp.Error.Errors {
err = packer.MultiErrorAppend(err, fmt.Errorf(e.Message))
err = packersdk.MultiErrorAppend(err, fmt.Errorf(e.Message))
}
}
}
@ -697,7 +696,7 @@ func (d *driverGCE) refreshZoneOp(zone string, op *compute.Operation) stateRefre
if newOp.Status == "DONE" {
if newOp.Error != nil {
for _, e := range newOp.Error.Errors {
err = packer.MultiErrorAppend(err, fmt.Errorf(e.Message))
err = packersdk.MultiErrorAppend(err, fmt.Errorf(e.Message))
}
}
}

View File

@ -8,7 +8,6 @@ import (
"strings"
"time"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -21,7 +20,7 @@ type StepCreateInstance struct {
func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string) (map[string]string, error) {
instanceMetadata := make(map[string]string)
var err error
var errs *packer.MultiError
var errs *packersdk.MultiError
// Copy metadata from config.
for k, v := range c.Metadata {
@ -75,7 +74,7 @@ func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string)
var content []byte
content, err = ioutil.ReadFile(value)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
instanceMetadata[key] = string(content)
}

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -95,46 +96,46 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.ServerName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID())
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.HCloudToken == "" {
// Required configurations that will display errors if not set
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("token for auth must be specified"))
}
if c.Location == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("location is required"))
}
if c.ServerType == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("server type is required"))
}
if c.Image == "" && c.ImageFilter == nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("image or image_filter is required"))
}
if c.ImageFilter != nil {
if len(c.ImageFilter.WithSelector) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("image_filter.with_selector is required when specifying filter"))
} else if c.Image != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("only one of image or image_filter can be specified"))
}
}
if c.UserData != "" && c.UserDataFile != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("only one of user_data or user_data_file can be specified"))
} else if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New(fmt.Sprintf("user_data_file not found: %s", c.UserDataFile)))
}
}

View File

@ -15,6 +15,7 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/json"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -265,39 +266,39 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
// Validation
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
errs = packer.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
errs = packersdk.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...)
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.Token == "" {
errs = packer.MultiErrorAppend(errs, errors.New("token is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("token is required"))
}
if c.VmType == "" {
errs = packer.MultiErrorAppend(errs, errors.New("vm type is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("vm type is required"))
}
if c.DiskSize == 0 {
errs = packer.MultiErrorAppend(errs, errors.New("disk size is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("disk size is required"))
}
if c.SourceImage == "" {
errs = packer.MultiErrorAppend(errs, errors.New("source image is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("source image is required"))
}
if c.ChrootDisk {
if len(c.PreMountCommands) == 0 {
errs = packer.MultiErrorAppend(errs, errors.New("pre-mount commands are required for chroot disk"))
errs = packersdk.MultiErrorAppend(errs, errors.New("pre-mount commands are required for chroot disk"))
}
}
for _, mounts := range c.ChrootMounts {
if len(mounts) != 3 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("each chroot_mounts entry should have three elements"))
break
}

View File

@ -105,21 +105,21 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)
packer.MultiErrorAppend(errs, commonErrs...)
packersdk.MultiErrorAppend(errs, commonErrs...)
warnings = append(warnings, commonWarns...)
if len(b.config.ISOConfig.ISOUrls) < 1 ||
@ -128,7 +128,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
//We only create a new hard drive if an existing one to copy from does not exist
err = b.checkDiskSize()
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
@ -139,7 +139,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.Generation == 2 {
if b.config.UseLegacyNetworkAdapter {
err = errors.New("Generation 2 vms don't support legacy network adapters.")
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
@ -147,17 +147,17 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.Generation > 1 && b.config.FixedVHD {
err = errors.New("Fixed VHD disks are only supported on Generation 1 virtual machines.")
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if !b.config.SkipCompaction && b.config.FixedVHD {
err = errors.New("Fixed VHD disks do not support compaction.")
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if b.config.DifferencingDisk && b.config.FixedVHD {
err = errors.New("Fixed VHD disks are not supported with differencing disks.")
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
// Warnings

View File

@ -12,6 +12,7 @@ import (
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -240,7 +241,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -98,23 +98,23 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
if b.config.RawSingleISOUrl != "" || len(b.config.ISOUrls) > 0 {
isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
}
errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
commonErrs, commonWarns := b.config.CommonConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)
packer.MultiErrorAppend(errs, commonErrs...)
packersdk.MultiErrorAppend(errs, commonErrs...)
warnings = append(warnings, commonWarns...)
if b.config.Cpu < 1 {
@ -123,22 +123,22 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.CloneFromVMName == "" {
if b.config.CloneFromVMCXPath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vm_name must be specified if "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vm_name must be specified if "+
"clone_from_vmcx_path is not specified."))
}
} else {
virtualMachineExists, err := powershell.DoesVirtualMachineExist(b.config.CloneFromVMName)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to clone "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to clone "+
"from exists: %s", err))
} else {
if !virtualMachineExists {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Virtual machine '%s' to clone from does not "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Virtual machine '%s' to clone from does not "+
"exist.", b.config.CloneFromVMName))
} else {
b.config.Generation, err = powershell.GetVirtualMachineGeneration(b.config.CloneFromVMName)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting virtual machine to clone "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting virtual machine to clone "+
"from generation: %s", err))
}
@ -146,11 +146,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
virtualMachineSnapshotExists, err := powershell.DoesVirtualMachineSnapshotExist(
b.config.CloneFromVMName, b.config.CloneFromSnapshotName)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine "+
"snapshot to clone from exists: %s", err))
} else {
if !virtualMachineSnapshotExists {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Virtual machine snapshot '%s' on "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Virtual machine snapshot '%s' on "+
"virtual machine '%s' to clone from does not exist.",
b.config.CloneFromSnapshotName, b.config.CloneFromVMName))
}
@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
virtualMachineOn, err := powershell.IsVirtualMachineOn(b.config.CloneFromVMName)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed detecting if virtual machine to "+
"clone is running: %s", err))
} else {
if virtualMachineOn {
@ -173,13 +173,13 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.CloneFromVMCXPath == "" {
if b.config.CloneFromVMName == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmcx_path be specified if "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The clone_from_vmcx_path be specified if "+
"clone_from_vm_name must is not specified."))
}
} else {
if _, err := os.Stat(b.config.CloneFromVMCXPath); os.IsNotExist(err) {
if err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("CloneFromVMCXPath does not exist: %s", err))
}
}
@ -190,7 +190,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
keep := strings.Split(b.config.CloneFromVMCXPath, "Virtual Machines")
b.config.CloneFromVMCXPath = keep[0]
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to "+
"parse the clone_from_vmcx_path to find the vm directory. "+
"Please provide the path to the folder containing the "+
"vmcx file, not the file itself. Example: instead of "+

View File

@ -12,6 +12,7 @@ import (
hypervcommon "github.com/hashicorp/packer/builder/hyperv/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -389,7 +390,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -31,9 +31,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, fmt.Errorf("[ERROR] Failed in decoding JSON->mapstructure")
}
errs := &packer.MultiError{}
errs = packer.MultiErrorAppend(errs, b.config.JDCloudCredentialConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.JDCloudInstanceSpecConfig.Prepare(&b.config.ctx)...)
errs := &packersdk.MultiError{}
errs = packersdk.MultiErrorAppend(errs, b.config.JDCloudCredentialConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.JDCloudInstanceSpecConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) != 0 {
return nil, nil, errs
}

View File

@ -14,6 +14,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -62,7 +63,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
// Defaults
@ -75,7 +76,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if def, err := interpolate.Render("packer-{{timestamp}}", nil); err == nil {
c.ImageLabel = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to render image name: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to render image name: %s", err))
}
}
@ -84,7 +85,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if def, err := interpolate.Render("packer-{{timestamp}}", nil); err == nil {
c.Label = def
} else {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to render Linode label: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to render Linode label: %s", err))
}
}
@ -92,7 +93,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
var err error
c.RootPass, err = createRandomRootPassword()
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Unable to generate root_pass: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Unable to generate root_pass: %s", err))
}
}
@ -102,29 +103,29 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
c.Comm.SSHPassword = c.RootPass
if c.PersonalAccessToken == "" {
// Required configurations that will display errors if not set
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("linode_token is required"))
}
if c.Region == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("region is required"))
}
if c.InstanceType == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("instance_type is required"))
}
if c.Image == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("image is required"))
}
@ -135,7 +136,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
for _, t := range c.Tags {
if !tagRe.MatchString(t) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("invalid tag: %s", t))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("invalid tag: %s", t))
}
}

View File

@ -8,8 +8,8 @@ import (
"os"
"time"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/mitchellh/mapstructure"
@ -80,7 +80,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.OutputDir == "" {
c.OutputDir = fmt.Sprintf("output-%s", c.PackerBuildName)
@ -103,7 +103,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if _, err := os.Stat(c.ConfigFile); os.IsNotExist(err) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("LXC Config file appears to be missing: %s", c.ConfigFile))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("LXC Config file appears to be missing: %s", c.ConfigFile))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -6,8 +6,8 @@ package lxd
import (
"fmt"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/mitchellh/mapstructure"
@ -56,7 +56,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.ContainerName == "" {
c.ContainerName = fmt.Sprintf("packer-%s", c.PackerBuildName)
@ -71,7 +71,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if c.Image == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("`image` is a required parameter for LXD. Please specify an image by alias or fingerprint. e.g. `ubuntu-daily:x`"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("`image` is a required parameter for LXD. Please specify an image by alias or fingerprint. e.g. `ubuntu-daily:x`"))
}
if c.Profile == "" {

View File

@ -11,8 +11,8 @@ import (
"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud"
"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -75,65 +75,65 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return warnings, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(nil); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.AccessKey == "" {
errs = packer.MultiErrorAppend(errs, errors.New("access_key is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("access_key is required"))
}
if c.SecretKey == "" {
errs = packer.MultiErrorAppend(errs, errors.New("secret_key is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("secret_key is required"))
}
if c.MemberServerImageNo == "" && c.ServerImageProductCode == "" {
errs = packer.MultiErrorAppend(errs, errors.New("server_image_product_code or member_server_image_no is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("server_image_product_code or member_server_image_no is required"))
}
if c.MemberServerImageNo != "" && c.ServerImageProductCode != "" {
errs = packer.MultiErrorAppend(errs, errors.New("Only one of server_image_product_code and member_server_image_no can be set"))
errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of server_image_product_code and member_server_image_no can be set"))
}
if c.ServerImageProductCode != "" && len(c.ServerImageProductCode) > 20 {
errs = packer.MultiErrorAppend(errs, errors.New("If server_image_product_code field is set, length of server_image_product_code should be max 20"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_product_code field is set, length of server_image_product_code should be max 20"))
}
if c.ServerProductCode != "" && len(c.ServerProductCode) > 20 {
errs = packer.MultiErrorAppend(errs, errors.New("If server_product_code field is set, length of server_product_code should be max 20"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If server_product_code field is set, length of server_product_code should be max 20"))
}
if c.ServerImageName != "" && (len(c.ServerImageName) < 3 || len(c.ServerImageName) > 30) {
errs = packer.MultiErrorAppend(errs, errors.New("If server_image_name field is set, length of server_image_name should be min 3 and max 20"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_name field is set, length of server_image_name should be min 3 and max 20"))
}
if c.ServerImageDescription != "" && len(c.ServerImageDescription) > 1000 {
errs = packer.MultiErrorAppend(errs, errors.New("If server_image_description field is set, length of server_image_description should be max 1000"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If server_image_description field is set, length of server_image_description should be max 1000"))
}
if c.BlockStorageSize != 0 {
if c.BlockStorageSize < 10 || c.BlockStorageSize > 2000 {
errs = packer.MultiErrorAppend(errs, errors.New("The size of BlockStorageSize is at least 10 GB and up to 2000GB"))
errs = packersdk.MultiErrorAppend(errs, errors.New("The size of BlockStorageSize is at least 10 GB and up to 2000GB"))
} else if int(c.BlockStorageSize/10)*10 != c.BlockStorageSize {
return nil, errors.New("BlockStorageSize must be a multiple of 10 GB")
}
}
if c.UserData != "" && c.UserDataFile != "" {
errs = packer.MultiErrorAppend(errs, errors.New("Only one of user_data or user_data_file can be specified."))
errs = packersdk.MultiErrorAppend(errs, errors.New("Only one of user_data or user_data_file can be specified."))
} else if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
}
}
if c.UserData != "" && len(c.UserData) > 21847 {
errs = packer.MultiErrorAppend(errs, errors.New("If user_data field is set, length of UserData should be max 21847"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If user_data field is set, length of UserData should be max 21847"))
}
if c.Comm.Type == "winrm" && c.AccessControlGroupConfigurationNo == "" {
errs = packer.MultiErrorAppend(errs, errors.New("If Communicator is winrm, access_control_group_configuration_no is required"))
errs = packersdk.MultiErrorAppend(errs, errors.New("If Communicator is winrm, access_control_group_configuration_no is required"))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -6,8 +6,8 @@ import (
"fmt"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -29,31 +29,31 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.CommConfig.Prepare(nil); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.CommConfig.Type != "none" {
if c.CommConfig.Host() == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("a Host must be specified, please reference your communicator documentation"))
}
if c.CommConfig.User() == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("a Username must be specified, please reference your communicator documentation"))
}
if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKeyFile == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("one authentication method must be specified, please reference your communicator documentation"))
}
if (c.CommConfig.SSHAgentAuth &&
(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKeyFile != "")) ||
(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKeyFile != "") {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified"))
}

View File

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/mitchellh/mapstructure"
@ -48,7 +49,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.SnapshotName == "" {
def, err := interpolate.Render("packer-{{timestamp}}", nil)
@ -61,7 +62,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.Image == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("1&1 'image' is required"))
}
@ -90,7 +91,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
dcs, err := api.ListDatacenters()
if err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, err)
}
for _, dc := range dcs {
@ -102,7 +103,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -51,10 +51,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs

View File

@ -36,9 +36,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
errs = packer.MultiErrorAppend(errs, b.config.PVConfig.Prepare(&b.config.ctx))
errs = packersdk.MultiErrorAppend(errs, b.config.PVConfig.Prepare(&b.config.ctx))
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs

View File

@ -10,8 +10,8 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -80,7 +80,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
// Validate that all required fields are present
var errs *packer.MultiError
var errs *packersdk.MultiError
required := map[string]string{
"username": c.Username,
"password": c.Password,
@ -92,7 +92,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
for k, v := range required {
if v == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("You must specify a %s.", k))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You must specify a %s.", k))
}
}
@ -107,20 +107,20 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
for _, ov := range objectValidation {
if !reValidObject.MatchString(ov.value) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s can contain only alphanumeric characters, hyphens, underscores, and periods.", ov.name))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s can contain only alphanumeric characters, hyphens, underscores, and periods.", ov.name))
}
}
if c.Attributes != "" && c.AttributesFile != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
} else if c.AttributesFile != "" {
if _, err := os.Stat(c.AttributesFile); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("attributes_file not found: %s", c.AttributesFile))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("attributes_file not found: %s", c.AttributesFile))
}
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if errs != nil && len(errs.Errors) > 0 {
@ -134,20 +134,20 @@ func (c *Config) Prepare(raws ...interface{}) error {
err := json.Unmarshal([]byte(c.Attributes), &data)
if err != nil {
err = fmt.Errorf("Problem parsing json from attributes: %s", err)
packer.MultiErrorAppend(errs, err)
packersdk.MultiErrorAppend(errs, err)
}
c.attribs = data
} else if c.AttributesFile != "" {
fidata, err := ioutil.ReadFile(c.AttributesFile)
if err != nil {
err = fmt.Errorf("Problem reading attributes_file: %s", err)
packer.MultiErrorAppend(errs, err)
packersdk.MultiErrorAppend(errs, err)
}
err = json.Unmarshal(fidata, &data)
c.attribs = data
if err != nil {
err = fmt.Errorf("Problem parsing json from attributes_file: %s", err)
packer.MultiErrorAppend(errs, err)
packersdk.MultiErrorAppend(errs, err)
}
c.attribs = data
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -82,19 +82,19 @@ func (c *PVConfig) IsPV() bool {
return c.PersistentVolumeSize > 0
}
func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packersdk.MultiError) {
if !c.IsPV() {
if c.BuilderShape != "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("`builder_shape` has no meaning when `persistent_volume_size` is not set."))
}
if c.BuilderImageList != "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("`builder_image_list` has no meaning when `persistent_volume_size` is not set."))
}
if c.BuilderImageListEntry != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("`builder_image_list_entry` has no meaning when `persistent_volume_size` is not set."))
}
return errs
@ -102,7 +102,7 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
c.BuilderComm.SSHPty = true
if c.BuilderComm.Type == "winrm" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("`ssh` is the only valid builder communicator type."))
}
@ -133,7 +133,7 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
}
if es := c.BuilderComm.Prepare(ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
return

View File

@ -16,6 +16,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
ocicommon "github.com/oracle/oci-go-sdk/common"
@ -129,9 +130,9 @@ func (c *Config) Prepare(raws ...interface{}) error {
return fmt.Errorf("Failed to mapstructure Config: %+v", err)
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
var tenancyOCID string
@ -143,28 +144,28 @@ func (c *Config) Prepare(raws ...interface{}) error {
// key involved.
var message string = " cannot be present when use_instance_principals is set to true."
if c.AccessCfgFile != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file"+message))
}
if c.AccessCfgFileAccount != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file_account"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_cfg_file_account"+message))
}
if c.UserID != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_ocid"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_ocid"+message))
}
if c.TenancyID != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("tenancy_ocid"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("tenancy_ocid"+message))
}
if c.Region != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("region"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("region"+message))
}
if c.Fingerprint != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("fingerprint"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("fingerprint"+message))
}
if c.KeyFile != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("key_file"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("key_file"+message))
}
if c.PassPhrase != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("pass_phrase"+message))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("pass_phrase"+message))
}
// This check is used to facilitate testing. During testing a Mock struct
// is assigned to c.configProvider otherwise testing fails because Instance
@ -235,23 +236,23 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if userOCID, _ := configProvider.UserOCID(); userOCID == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'user_ocid' must be specified"))
}
tenancyOCID, _ = configProvider.TenancyOCID()
if tenancyOCID == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'tenancy_ocid' must be specified"))
}
if fingerprint, _ := configProvider.KeyFingerprint(); fingerprint == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'fingerprint' must be specified"))
}
if _, err := configProvider.PrivateRSAKey(); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'key_file' must be specified"))
}
@ -259,7 +260,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if c.AvailabilityDomain == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'availability_domain' must be specified"))
}
@ -272,12 +273,12 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if c.Shape == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'shape' must be specified"))
}
if (c.SubnetID == "") && (c.CreateVnicDetails.SubnetId == nil) {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'subnet_ocid' must be specified"))
}
@ -289,7 +290,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
}
if (c.BaseImageID == "") && (c.BaseImageFilter == ListImagesRequest{}) {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'base_image_ocid' or 'base_image_filter' must be specified"))
}
@ -307,19 +308,19 @@ func (c *Config) Prepare(raws ...interface{}) error {
k = strings.TrimSpace(k)
v = strings.TrimSpace(v)
if len(k) > 100 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Tag key length too long. Maximum 100 but found %d. Key: %s", len(k), k))
}
if len(k) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("Tag key empty in config"))
}
if len(v) > 100 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Tag value length too long. Maximum 100 but found %d. Key: %s", len(v), k))
}
if len(v) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("Tag value empty in config"))
}
}
@ -328,7 +329,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
if c.ImageName == "" {
name, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("unable to parse image name: %s", err))
} else {
c.ImageName = name
@ -337,17 +338,17 @@ func (c *Config) Prepare(raws ...interface{}) error {
// Optional UserData config
if c.UserData != "" && c.UserDataFile != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Only one of user_data or user_data_file can be specified."))
} else if c.UserDataFile != "" {
if _, err := os.Stat(c.UserDataFile); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("user_data_file not found: %s", c.UserDataFile))
}
}
// read UserDataFile into string.
if c.UserDataFile != "" {
fiData, err := ioutil.ReadFile(c.UserDataFile)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Problem reading user_data_file: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Problem reading user_data_file: %s", err))
}
c.UserData = string(fiData)
}
@ -364,7 +365,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
if c.BootVolumeSizeInGBs == 0 {
c.BootVolumeSizeInGBs = 50
} else if c.BootVolumeSizeInGBs < 50 || c.BootVolumeSizeInGBs > 16384 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("'disk_size' must be between 50 and 16384 GBs"))
}

View File

@ -70,12 +70,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs

View File

@ -71,16 +71,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RootDevice.Prepare(&b.config.ctx)...)
if b.config.OMIVirtType == "" {
errs = packer.MultiErrorAppend(errs, errors.New("omi_virtualization_type is required."))
errs = packersdk.MultiErrorAppend(errs, errors.New("omi_virtualization_type is required."))
}
foundRootVolume := false
@ -91,7 +91,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if !foundRootVolume {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -8,7 +8,7 @@ import (
"strings"
"github.com/antihax/optional"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/outscale/osc-sdk-go/osc"
)
@ -87,7 +87,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -64,20 +64,20 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
for _, d := range b.config.VolumeMappings {
if err := d.Prepare(&b.config.ctx); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("OMIMapping: %s", err.Error()))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("OMIMapping: %s", err.Error()))
}
}
b.config.launchBlockDevices, err = commonBlockDevices(b.config.VolumeMappings, &b.config.ctx)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -128,16 +128,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors or warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
var warns []string
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs,
b.config.OMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
for _, mounts := range b.config.ChrootMounts {
if len(mounts) != 3 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("Each chroot_mounts entry should be three elements."))
break
}
@ -148,28 +148,28 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
warns = append(warns, "source_omi and source_omi_filter are unused when from_scratch is true")
}
if b.config.RootVolumeSize == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("root_volume_size is required with from_scratch."))
}
if len(b.config.PreMountCommands) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("pre_mount_commands is required with from_scratch."))
}
if b.config.OMIVirtType == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("omi_virtualization_type is required with from_scratch."))
}
if b.config.RootDeviceName == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("root_device_name is required with from_scratch."))
}
if len(b.config.OMIMappings) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("omi_block_device_mappings is required with from_scratch."))
}
} else {
if b.config.SourceOMI == "" && b.config.SourceOMIFilter.Empty() {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("source_omi or source_omi_filter is required."))
}
if len(b.config.OMIMappings) != 0 {

View File

@ -8,7 +8,7 @@ import (
"strings"
"github.com/antihax/optional"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/outscale/osc-sdk-go/osc"
)
@ -111,7 +111,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -106,25 +106,25 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(
errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.PrlctlConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.PrlctlPostConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.PrlctlVersionConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.HWConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlPostConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.PrlctlVersionConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
if b.config.DiskSize == 0 {
b.config.DiskSize = 40000
@ -152,7 +152,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if b.config.DiskType != "expand" && b.config.DiskType != "plain" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("disk_type can only be expand, or plain"))
}
@ -163,7 +163,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("hard_drive_interface can only be ide, sata, or scsi"))
}

View File

@ -6,6 +6,7 @@ import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -92,7 +93,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -8,10 +8,10 @@ import (
"os"
parallelscommon "github.com/hashicorp/packer/builder/parallels/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -73,22 +73,22 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
// Prepare the errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, c.PrlctlConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.PrlctlPostConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.PrlctlVersionConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.PrlctlConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.PrlctlPostConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.PrlctlVersionConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
if c.SourcePath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
} else {
if _, err := os.Stat(c.SourcePath); err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("source_path is invalid: %s", err))
}
}

View File

@ -6,7 +6,7 @@ import (
"os"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig(t *testing.T) map[string]interface{} {
@ -90,7 +90,7 @@ func TestNewConfig_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -9,6 +9,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/mitchellh/mapstructure"
@ -51,10 +52,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.Comm.SSHPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("Either ssh private key path or ssh password must be set."))
}
@ -101,21 +102,21 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.Image == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("ProfitBricks 'image' is required"))
}
if c.PBUsername == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("ProfitBricks username is required"))
}
if c.PBPassword == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("ProfitBricks password is required"))
}

View File

@ -4,7 +4,7 @@ package proxmoxclone
import (
proxmox "github.com/hashicorp/packer/builder/proxmox/common"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
)
@ -16,10 +16,10 @@ type Config struct {
}
func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {
var errs *packer.MultiError
var errs *packersdk.MultiError
_, warnings, merrs := c.Config.Prepare(c, raws...)
if merrs != nil {
errs = packer.MultiErrorAppend(errs, merrs)
errs = packersdk.MultiErrorAppend(errs, merrs)
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -16,6 +16,7 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -119,7 +120,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
return nil, nil, err
}
var errs *packer.MultiError
var errs *packersdk.MultiError
var warnings []string
packer.LogSecretFilter.Set(c.Password)
@ -138,7 +139,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
var err error
c.BootKeyInterval, err = time.ParseDuration(os.Getenv(bootcommand.PackerKeyEnv))
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
if c.BootKeyInterval == 0 {
@ -191,11 +192,11 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
if c.Disks[idx].IOThread {
// io thread is only supported by virtio-scsi-single controller
if c.SCSIController != "virtio-scsi-single" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("io thread option requires virtio-scsi-single controller"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("io thread option requires virtio-scsi-single controller"))
} else {
// ... and only for virtio and scsi disks
if !(c.Disks[idx].Type == "scsi" || c.Disks[idx].Type == "virtio") {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("io thread option requires scsi or a virtio disk"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("io thread option requires scsi or a virtio disk"))
}
}
}
@ -203,7 +204,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
// (currently zfspool|lvm|rbd|cephfs), the format parameter is mandatory. Make sure this is still up to date
// when updating the vendored code!
if !contains([]string{"zfspool", "lvm", "rbd", "cephfs"}, c.Disks[idx].StoragePoolType) && c.Disks[idx].DiskFormat == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("disk format must be specified for pool type %q", c.Disks[idx].StoragePoolType))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disk format must be specified for pool type %q", c.Disks[idx].StoragePoolType))
}
}
if c.SCSIController == "" {
@ -211,43 +212,43 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
c.SCSIController = "lsi"
}
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.Ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.Ctx)...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.Ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.Ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.Ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.Ctx)...)
// Required configurations that will display errors if not set
if c.Username == "" {
errs = packer.MultiErrorAppend(errs, errors.New("username must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("username must be specified"))
}
if c.Password == "" {
errs = packer.MultiErrorAppend(errs, errors.New("password must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("password must be specified"))
}
if c.ProxmoxURLRaw == "" {
errs = packer.MultiErrorAppend(errs, errors.New("proxmox_url must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("proxmox_url must be specified"))
}
if c.proxmoxURL, err = url.Parse(c.ProxmoxURLRaw); err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Could not parse proxmox_url: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Could not parse proxmox_url: %s", err))
}
if c.Node == "" {
errs = packer.MultiErrorAppend(errs, errors.New("node must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("node must be specified"))
}
if strings.ContainsAny(c.TemplateName, " ") {
errs = packer.MultiErrorAppend(errs, errors.New("template_name must not contain spaces"))
errs = packersdk.MultiErrorAppend(errs, errors.New("template_name must not contain spaces"))
}
for idx := range c.NICs {
if c.NICs[idx].Bridge == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].bridge must be specified", idx))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].bridge must be specified", idx))
}
if c.NICs[idx].Model != "virtio" && c.NICs[idx].PacketQueues > 0 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].packet_queues can only be set for 'virtio' driver", idx))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("network_adapters[%d].packet_queues can only be set for 'virtio' driver", idx))
}
}
for idx := range c.Disks {
if c.Disks[idx].StoragePool == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool must be specified", idx))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool must be specified", idx))
}
if c.Disks[idx].StoragePoolType == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool_type must be specified", idx))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool_type must be specified", idx))
}
}

View File

@ -4,7 +4,7 @@ import (
"strings"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func mandatoryConfig(t *testing.T) map[string]interface{} {
@ -23,9 +23,9 @@ func TestRequiredParameters(t *testing.T) {
if err == nil {
t.Fatal("Expected empty configuration to fail")
}
errs, ok := err.(*packer.MultiError)
errs, ok := err.(*packersdk.MultiError)
if !ok {
t.Fatal("Expected errors to be packer.MultiError")
t.Fatal("Expected errors to be packersdk.MultiError")
}
required := []string{"username", "password", "proxmox_url", "node", "ssh_username"}

View File

@ -10,8 +10,8 @@ import (
"strings"
proxmox "github.com/hashicorp/packer/builder/proxmox/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
type Config struct {
@ -25,10 +25,10 @@ type Config struct {
}
func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {
var errs *packer.MultiError
var errs *packersdk.MultiError
_, warnings, merrs := c.Config.Prepare(c, raws...)
if merrs != nil {
errs = packer.MultiErrorAppend(errs, merrs)
errs = packersdk.MultiErrorAppend(errs, merrs)
}
// Check ISO config
@ -39,16 +39,16 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {
c.shouldUploadISO = false
} else {
isoWarnings, isoErrors := c.ISOConfig.Prepare(&c.Ctx)
errs = packer.MultiErrorAppend(errs, isoErrors...)
errs = packersdk.MultiErrorAppend(errs, isoErrors...)
warnings = append(warnings, isoWarnings...)
c.shouldUploadISO = true
}
if (c.ISOFile == "" && len(c.ISOConfig.ISOUrls) == 0) || (c.ISOFile != "" && len(c.ISOConfig.ISOUrls) != 0) {
errs = packer.MultiErrorAppend(errs, errors.New("either iso_file or iso_url, but not both, must be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("either iso_file or iso_url, but not both, must be specified"))
}
if len(c.ISOConfig.ISOUrls) != 0 && c.ISOStoragePool == "" {
errs = packer.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified"))
}
for idx := range c.AdditionalISOFiles {
@ -61,7 +61,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {
} else {
c.AdditionalISOFiles[idx].DownloadPathKey = "downloaded_additional_iso_path_" + strconv.Itoa(idx)
isoWarnings, isoErrors := c.AdditionalISOFiles[idx].ISOConfig.Prepare(&c.Ctx)
errs = packer.MultiErrorAppend(errs, isoErrors...)
errs = packersdk.MultiErrorAppend(errs, isoErrors...)
warnings = append(warnings, isoWarnings...)
c.AdditionalISOFiles[idx].ShouldUploadISO = true
}
@ -72,38 +72,38 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {
if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "ide") {
busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[3:])
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[3:]))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[3:]))
}
if busnumber == 2 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("IDE bus 2 is used by boot ISO"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("IDE bus 2 is used by boot ISO"))
}
if busnumber > 3 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("IDE bus index can't be higher than 3"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("IDE bus index can't be higher than 3"))
}
}
if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "sata") {
busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[4:])
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:]))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:]))
}
if busnumber > 5 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("SATA bus index can't be higher than 5"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SATA bus index can't be higher than 5"))
}
}
if strings.HasPrefix(c.AdditionalISOFiles[idx].Device, "scsi") {
busnumber, err := strconv.Atoi(c.AdditionalISOFiles[idx].Device[4:])
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:]))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("%s is not a valid bus index", c.AdditionalISOFiles[idx].Device[4:]))
}
if busnumber > 30 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("SCSI bus index can't be higher than 30"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SCSI bus index can't be higher than 30"))
}
}
if (c.AdditionalISOFiles[idx].ISOFile == "" && len(c.AdditionalISOFiles[idx].ISOConfig.ISOUrls) == 0) || (c.AdditionalISOFiles[idx].ISOFile != "" && len(c.AdditionalISOFiles[idx].ISOConfig.ISOUrls) != 0) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("either iso_file or iso_url, but not both, must be specified for AdditionalISO file %s", c.AdditionalISOFiles[idx].Device))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("either iso_file or iso_url, but not both, must be specified for AdditionalISO file %s", c.AdditionalISOFiles[idx].Device))
}
if len(c.ISOConfig.ISOUrls) != 0 && c.ISOStoragePool == "" {
errs = packer.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified"))
errs = packersdk.MultiErrorAppend(errs, errors.New("when specifying iso_url, iso_storage_pool must also be specified"))
}
}

View File

@ -13,10 +13,10 @@ import (
"runtime"
"strings"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -410,10 +410,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
if c.DiskSize == "" || c.DiskSize == "0" {
c.DiskSize = "40960M"
@ -423,7 +423,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
re := regexp.MustCompile(`^[\d]+(b|k|m|g|t){0,1}$`)
matched := re.MatchString(strings.ToLower(c.DiskSize))
if !matched {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Invalid disk size."))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Invalid disk size."))
} else {
// Okay, it's valid -- if it doesn't alreay have a suffix, then
// append "M" as the default unit.
@ -510,9 +510,9 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.Format = "qcow2"
}
errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
if c.NetDevice == "" {
c.NetDevice = "virtio-net"
@ -527,17 +527,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
commConfigWarnings, es := c.CommConfig.Prepare(&c.ctx)
if len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
warnings = append(warnings, commConfigWarnings...)
if !(c.Format == "qcow2" || c.Format == "raw") {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("invalid format, only 'qcow2' or 'raw' are allowed"))
}
@ -549,61 +549,61 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.UseBackingFile {
c.SkipCompaction = true
if !(c.DiskImage && c.Format == "qcow2") {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("use_backing_file can only be enabled for QCOW2 images and when disk_image is true"))
}
}
if c.DiskImage && len(c.AdditionalDiskSize) > 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("disk_additional_size can only be used when disk_image is false"))
}
if c.SkipResizeDisk && !(c.DiskImage) {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("skip_resize_disk can only be used when disk_image is true"))
}
if _, ok := accels[c.Accelerator]; !ok {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("invalid accelerator, only 'kvm', 'tcg', 'xen', 'hax', 'hvf', 'whpx', or 'none' are allowed"))
}
if _, ok := diskInterface[c.DiskInterface]; !ok {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("unrecognized disk interface type"))
}
if _, ok := diskCache[c.DiskCache]; !ok {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("unrecognized disk cache type"))
}
if _, ok := diskDiscard[c.DiskDiscard]; !ok {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("unrecognized disk discard type"))
}
if _, ok := diskDZeroes[c.DetectZeroes]; !ok {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("unrecognized disk detect zeroes setting"))
}
if !c.PackerForce {
if _, err := os.Stat(c.OutputDir); err == nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs,
fmt.Errorf("Output directory '%s' already exists. It must not exist.", c.OutputDir))
}
}
if c.VNCPortMin > c.VNCPortMax {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max"))
}
if c.NetBridge != "" && runtime.GOOS != "linux" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("net_bridge is only supported in Linux based OSes"))
}

View File

@ -10,6 +10,7 @@ import (
"time"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/stretchr/testify/assert"
)
@ -354,7 +355,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/useragent"
@ -221,17 +222,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c.BootType = instance.BootTypeLocal.String()
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
if c.ProjectID == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("scaleway Project ID must be specified"))
}
if c.SecretKey == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("scaleway Secret Key must be specified"))
}
@ -241,17 +242,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.Zone == "" {
errs = packer.MultiErrorAppend(
errs, errors.New("scaleway Zone is required"))
errs = packersdk.MultiErrorAppend(
errs, errors.New("Scaleway Zone is required"))
}
if c.CommercialType == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("commercial type is required"))
}
if c.Image == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("image is required"))
}

View File

@ -7,7 +7,7 @@ import (
"sort"
"strings"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
)
@ -133,7 +133,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else if len(errors) > 1 {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
} else {
return nil
}

View File

@ -52,10 +52,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.TencentCloudAccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.TencentCloudImageConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.TencentCloudRunConfig.Prepare(&b.config.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudAccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudImageConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.TencentCloudRunConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs
}

View File

@ -6,7 +6,7 @@ import (
"sort"
"strings"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/ucloud/ucloud-sdk-go/ucloud"
)
@ -84,7 +84,7 @@ func (a *Artifact) Destroy() error {
if len(errors) == 1 {
return errors[0]
} else {
return &packer.MultiError{Errors: errors}
return &packersdk.MultiError{Errors: errors}
}
}

View File

@ -55,10 +55,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
var errs *packersdk.MultiError
errs = packersdk.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ImageConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if errs != nil && len(errs.Errors) > 0 {
return nil, nil, errs

View File

@ -4,7 +4,6 @@ import (
"context"
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -38,14 +37,14 @@ func (s *stepPreValidate) validateProjectIds(state multistep.StateBag) error {
ui.Say("Validating project_id and copied project_ids...")
var errs *packer.MultiError
var errs *packersdk.MultiError
if err := config.ValidateProjectId(s.ProjectId); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
for _, imageDestination := range s.ImageDestinations {
if err := config.ValidateProjectId(imageDestination.ProjectId); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
@ -62,13 +61,13 @@ func (s *stepPreValidate) validateRegions(state multistep.StateBag) error {
ui.Say("Validating region and copied regions...")
var errs *packer.MultiError
var errs *packersdk.MultiError
if err := config.ValidateRegion(s.Region); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
for _, imageDestination := range s.ImageDestinations {
if err := config.ValidateRegion(imageDestination.Region); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
}
@ -85,9 +84,9 @@ func (s *stepPreValidate) validateZones(state multistep.StateBag) error {
ui.Say("Validating availability_zone...")
var errs *packer.MultiError
var errs *packersdk.MultiError
if err := config.ValidateZone(s.Region, s.Zone); err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -167,7 +167,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
if b.config.OutputDir == "" {
@ -179,7 +179,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if b.config.Comm.Type != "ssh" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf(`The Vagrant builder currently only supports the ssh communicator"`))
}
// The box isn't a namespace like you'd pull from vagrant cloud
@ -189,11 +189,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.SourceBox == "" {
if b.config.GlobalID == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required unless you have set global_id"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required unless you have set global_id"))
}
} else {
if b.config.GlobalID != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("You may either set global_id or source_path but not both"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You may either set global_id or source_path but not both"))
}
// We're about to open up an actual boxfile. If the file is local to the
// filesystem, let's make sure it exists before we get too far into the
@ -204,7 +204,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
u, err := url.Parse(b.config.SourceBox)
if err == nil && (u.Scheme == "" || u.Scheme == "file") {
if _, err := os.Stat(b.config.SourceBox); err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Source box '%s' needs to exist at time of"+
" config validation! %v", b.config.SourceBox, err))
}
@ -215,7 +215,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.OutputVagrantfile != "" {
b.config.OutputVagrantfile, err = filepath.Abs(b.config.OutputVagrantfile)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("unable to determine absolute path for output vagrantfile: %s", err))
}
}
@ -224,7 +224,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
for i, rawFile := range b.config.PackageInclude {
inclFile, err := filepath.Abs(rawFile)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("unable to determine absolute path for file to be included: %s", rawFile))
}
b.config.PackageInclude[i] = inclFile
@ -248,7 +248,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
}
if !matches {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf(`TeardownMethod must be "halt", "suspend", or "destroy"`))
}
}
@ -256,11 +256,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if b.config.SyncedFolder != "" {
b.config.SyncedFolder, err = filepath.Abs(b.config.SyncedFolder)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("unable to determine absolute path for synced_folder: %s", b.config.SyncedFolder))
}
if _, err := os.Stat(b.config.SyncedFolder); err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("synced_folder \"%s\" does not exist on the Packer host.", b.config.SyncedFolder))
}
}

View File

@ -137,18 +137,18 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
// Accumulate any errors and warnings
var errs *packer.MultiError
var errs *packersdk.MultiError
warnings := make([]string, 0)
isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
errs = packer.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.ExportConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.FloppyConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, b.config.CDConfig.Prepare(&b.config.ctx)...)
errs = packersdk.MultiErrorAppend(
errs, b.config.OutputConfig.Prepare(&b.config.ctx, &b.config.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, b.config.HTTPConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
@ -190,7 +190,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
case "ide", "sata", "scsi", "pcie":
// do nothing
default:
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("hard_drive_interface can only be ide, sata, pcie or scsi"))
}
@ -199,7 +199,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if b.config.SATAPortCount > 30 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("sata_port_count cannot be greater than 30"))
}
@ -208,12 +208,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}
if b.config.NVMePortCount > 255 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("nvme_port_count cannot be greater than 255"))
}
if b.config.ISOInterface != "ide" && b.config.ISOInterface != "sata" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("iso_interface can only be ide or sata"))
}

View File

@ -7,6 +7,7 @@ import (
"github.com/hashicorp/packer/builder/virtualbox/common"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -132,7 +133,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -123,7 +124,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...)
if c.SourcePath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
}
if c.GuestAdditionsInterface == "" {

View File

@ -6,7 +6,7 @@ import (
"os"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig(t *testing.T) map[string]interface{} {
@ -50,7 +50,7 @@ func TestNewConfig_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -103,7 +104,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.CommConfig.Comm.Type)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.GuestAdditionsConfig.Prepare(c.CommConfig.Comm.Type)...)
if c.GuestAdditionsInterface == "" {
c.GuestAdditionsInterface = "ide"
}
@ -111,7 +111,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
log.Printf("PostShutdownDelay: %s", c.PostShutdownDelay)
if c.VMName == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("vm_name is required"))
}
@ -131,15 +131,15 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
driver, err := vboxcommon.NewDriver()
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed creating VirtualBox driver: %s", err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed creating VirtualBox driver: %s", err))
} else {
if c.AttachSnapshot != "" && c.TargetSnapshot != "" && c.AttachSnapshot == c.TargetSnapshot {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Attach snapshot %s and target snapshot %s cannot be the same", c.AttachSnapshot, c.TargetSnapshot))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Attach snapshot %s and target snapshot %s cannot be the same", c.AttachSnapshot, c.TargetSnapshot))
}
snapshotTree, err := driver.LoadSnapshots(c.VMName)
log.Printf("")
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed to load snapshots for VM %s: %s", c.VMName, err))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Failed to load snapshots for VM %s: %s", c.VMName, err))
} else {
log.Printf("Snapshots loaded from VM %s", c.VMName)
@ -151,13 +151,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.AttachSnapshot != "" {
log.Printf("Checking configuration attach_snapshot [%s]", c.AttachSnapshot)
if nil == snapshotTree {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("No snapshots defined on VM %s. Unable to attach to %s", c.VMName, c.AttachSnapshot))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("No snapshots defined on VM %s. Unable to attach to %s", c.VMName, c.AttachSnapshot))
} else {
snapshots := snapshotTree.GetSnapshotsByName(c.AttachSnapshot)
if 0 >= len(snapshots) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Snapshot %s does not exist on VM %s", c.AttachSnapshot, c.VMName))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Snapshot %s does not exist on VM %s", c.AttachSnapshot, c.VMName))
} else if 1 < len(snapshots) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Multiple Snapshots with name %s exist on VM %s", c.AttachSnapshot, c.VMName))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Multiple Snapshots with name %s exist on VM %s", c.AttachSnapshot, c.VMName))
} else {
attachSnapshot = snapshots[0]
}
@ -169,7 +169,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
log.Printf("Currently no snapshots defined in VM %s", c.VMName)
} else {
if c.TargetSnapshot == attachSnapshot.Name {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s cannot be the same as the snapshot to which the builder shall attach: %s", c.TargetSnapshot, attachSnapshot.Name))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s cannot be the same as the snapshot to which the builder shall attach: %s", c.TargetSnapshot, attachSnapshot.Name))
} else {
snapshots := snapshotTree.GetSnapshotsByName(c.TargetSnapshot)
if 0 < len(snapshots) {
@ -182,9 +182,9 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
isChild = nil != snapshot.Parent && snapshot.Parent.UUID == attachSnapshot.UUID
}
if !isChild {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists and is not a direct child of %s", c.TargetSnapshot, attachSnapshot.Name))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists and is not a direct child of %s", c.TargetSnapshot, attachSnapshot.Name))
} else if !c.DeleteTargetSnapshot {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists as direct child of %s for VM %s. Use force_delete_snapshot = true to overwrite snapshot",
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("Target snapshot %s already exists as direct child of %s for VM %s. Use force_delete_snapshot = true to overwrite snapshot",
c.TargetSnapshot,
attachSnapshot.Name,
c.VMName))

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func testConfig() map[string]interface{} {
@ -134,7 +135,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -10,10 +10,10 @@ import (
"strings"
vmwcommon "github.com/hashicorp/packer/builder/vmware/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -96,27 +96,27 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors and warnings
var warnings []string
var errs *packer.MultiError
var errs *packersdk.MultiError
runConfigWarnings, runConfigErrs := c.RunConfig.Prepare(&c.ctx, &c.DriverConfig)
warnings = append(warnings, runConfigWarnings...)
errs = packer.MultiErrorAppend(errs, runConfigErrs...)
errs = packersdk.MultiErrorAppend(errs, runConfigErrs...)
isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.HWConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.HWConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.VMXConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...)
if c.DiskSize == 0 {
c.DiskSize = 40000
@ -134,7 +134,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.RemoteType == "esx5" {
if c.DiskTypeId != "thin" && !c.SkipCompaction {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("skip_compaction must be 'true' for disk_type_id: %s", c.DiskTypeId))
}
}
@ -153,7 +153,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.VMXTemplatePath != "" {
if err := c.validateVMXTemplatePath(); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("vmx_template_path is invalid: %s", err))
}
} else {
@ -191,13 +191,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
err = c.DriverConfig.Validate(c.SkipExport)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if c.CdromAdapterType != "" {
c.CdromAdapterType = strings.ToLower(c.CdromAdapterType)
if c.CdromAdapterType != "ide" && c.CdromAdapterType != "sata" && c.CdromAdapterType != "scsi" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("cdrom_adapter_type must be one of ide, sata, or scsi"))
}
}

View File

@ -7,7 +7,7 @@ import (
"reflect"
"testing"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
func TestBuilderPrepare_FloppyFiles(t *testing.T) {
@ -62,7 +62,7 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Nonexistent floppies should trigger multierror")
}
if len(errs.(*packer.MultiError).Errors) != 2 {
if len(errs.(*packersdk.MultiError).Errors) != 2 {
t.Fatalf("Multierror should work and report 2 errors")
}
}

View File

@ -8,10 +8,10 @@ import (
"os"
vmwcommon "github.com/hashicorp/packer/builder/vmware/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shutdowncommand"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -81,30 +81,30 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors and warnings
var warnings []string
var errs *packer.MultiError
var errs *packersdk.MultiError
runConfigWarnings, runConfigErrs := c.RunConfig.Prepare(&c.ctx, &c.DriverConfig)
warnings = append(warnings, runConfigWarnings...)
errs = packer.MultiErrorAppend(errs, runConfigErrs...)
errs = packer.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, runConfigErrs...)
errs = packersdk.MultiErrorAppend(errs, c.DriverConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.OutputConfig.Prepare(&c.ctx, &c.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.FloppyConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.VNCConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ExportConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.DiskConfig.Prepare(&c.ctx)...)
if c.RemoteType == "" {
if c.SourcePath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("source_path is blank, but is required"))
} else {
if _, err := os.Stat(c.SourcePath); err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("source_path is invalid: %s", err))
}
}
@ -141,7 +141,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
err = c.DriverConfig.Validate(c.SkipExport)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
if c.ShutdownCommand == "" {

View File

@ -6,9 +6,9 @@ package clone
import (
"github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
packerCommon "github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -67,33 +67,33 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
// warnings := make([]string, 0)
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
errs = packer.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.CloneConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.LocationConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.CloneConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.LocationConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
_, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm)
// shutdownWarnings, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm)
// warnings = append(warnings, shutdownWarnings...)
errs = packer.MultiErrorAppend(errs, shutdownErrs...)
errs = packersdk.MultiErrorAppend(errs, shutdownErrs...)
if c.Export != nil {
errs = packer.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...)
}
if c.ContentLibraryDestinationConfig != nil {
errs = packer.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...)
}
if c.CustomizeConfig != nil {
errs = packer.MultiErrorAppend(errs, c.CustomizeConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.CustomizeConfig.Prepare()...)
}
if len(errs.Errors) > 0 {

View File

@ -17,7 +17,6 @@ import (
"strings"
"github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
@ -103,16 +102,16 @@ var sha = map[string]func() hash.Hash{
}
func (c *ExportConfig) Prepare(ctx *interpolate.Context, lc *LocationConfig, pc *common.PackerConfig) []error {
var errs *packer.MultiError
var errs *packersdk.MultiError
errs = packer.MultiErrorAppend(errs, c.OutputDir.Prepare(ctx, pc)...)
errs = packersdk.MultiErrorAppend(errs, c.OutputDir.Prepare(ctx, pc)...)
// manifest should default to sha256
if c.Manifest == "" {
c.Manifest = "sha256"
}
if _, ok := sha[c.Manifest]; !ok {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("unknown hash: %s. available options include available options being 'none', 'sha1', 'sha256', 'sha512'", c.Manifest))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("unknown hash: %s. available options include available options being 'none', 'sha1', 'sha256', 'sha512'", c.Manifest))
}
if c.Name == "" {
@ -121,12 +120,12 @@ func (c *ExportConfig) Prepare(ctx *interpolate.Context, lc *LocationConfig, pc
target := getTarget(c.OutputDir.OutputDir, c.Name)
if !c.Force {
if _, err := os.Stat(target); err == nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("file already exists: %s", target))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("file already exists: %s", target))
}
}
if err := os.MkdirAll(c.OutputDir.OutputDir, c.OutputDir.DirPerm); err != nil {
errs = packer.MultiErrorAppend(errs, errors.Wrap(err, "unable to make directory for export"))
errs = packersdk.MultiErrorAppend(errs, errors.Wrap(err, "unable to make directory for export"))
}
if errs != nil && len(errs.Errors) > 0 {

View File

@ -7,7 +7,6 @@ import (
"fmt"
"github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -67,10 +66,10 @@ type ContentLibraryDestinationConfig struct {
}
func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error {
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.Library == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("a library name must be provided"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("a library name must be provided"))
}
if c.Ovf {
@ -79,7 +78,7 @@ func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error {
}
} else {
if c.Name == lc.VMName {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("the content library destination name must be different from the VM name"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("the content library destination name must be different from the VM name"))
}
if c.Name == "" {
@ -87,7 +86,7 @@ func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error {
// otherwise vSphere won't be able to create the template which will be imported
name, err := interpolate.Render(lc.VMName+"{{timestamp}}", nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("unable to parse content library VM template name: %s", err))
}
c.Name = name

View File

@ -6,9 +6,9 @@ package iso
import (
"github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
packerCommon "github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -68,35 +68,35 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
warnings := make([]string, 0)
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
if c.ISOUrls != nil || c.RawSingleISOUrl != "" {
isoWarnings, isoErrs := c.ISOConfig.Prepare(&c.ctx)
warnings = append(warnings, isoWarnings...)
errs = packer.MultiErrorAppend(errs, isoErrs...)
errs = packersdk.MultiErrorAppend(errs, isoErrs...)
}
errs = packer.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.CreateConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.LocationConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.ConnectConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.CreateConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.LocationConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.HardwareConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.HTTPConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...)
errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.CDRomConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.CDConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.WaitIpConfig.Prepare()...)
errs = packersdk.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...)
shutdownWarnings, shutdownErrs := c.ShutdownConfig.Prepare(c.Comm)
warnings = append(warnings, shutdownWarnings...)
errs = packer.MultiErrorAppend(errs, shutdownErrs...)
errs = packersdk.MultiErrorAppend(errs, shutdownErrs...)
if c.Export != nil {
errs = packer.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.Export.Prepare(&c.ctx, &c.LocationConfig, &c.PackerConfig)...)
}
if c.ContentLibraryDestinationConfig != nil {
errs = packer.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...)
errs = packersdk.MultiErrorAppend(errs, c.ContentLibraryDestinationConfig.Prepare(&c.LocationConfig)...)
}
if len(errs.Errors) > 0 {

View File

@ -11,8 +11,8 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
@ -130,13 +130,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
errs = packer.MultiErrorAppend(errs, c.AccessConfig.Prepare(&c.ctx)...)
errs = packersdk.MultiErrorAppend(errs, c.AccessConfig.Prepare(&c.ctx)...)
if c.SerialLogFile != "" {
if _, err := os.Stat(c.SerialLogFile); os.IsExist(err) {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Serial log file %s already exist", c.SerialLogFile))
}
}
@ -162,7 +162,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.ImageMinDiskSizeGb < c.DiskSizeGb {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Invalid image_min_disk_size value (%d): Must be equal or greate than disk_size_gb (%d)",
c.ImageMinDiskSizeGb, c.DiskSizeGb))
}
@ -174,7 +174,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if c.ImageName == "" {
img, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Unable to render default image name: %s ", err))
} else {
c.ImageName = img
@ -182,13 +182,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if len(c.ImageFamily) > 63 {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Invalid image family: Must not be longer than 63 characters"))
}
if c.ImageFamily != "" {
if !reImageFamily.MatchString(c.ImageFamily) {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Invalid image family: The first character must be a "+
"lowercase letter, and all following characters must be a dash, "+
"lowercase letter, or digit, except the last character, which cannot be a dash"))
@ -211,17 +211,17 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if es := c.Communicator.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
errs = packersdk.MultiErrorAppend(errs, es...)
}
// Process required parameters.
if c.SourceImageID == "" {
if c.SourceImageFamily == "" && c.SourceImageName == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a source_image_name or source_image_family must be specified"))
}
if c.SourceImageFamily != "" && c.SourceImageName != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("one of source_image_name or source_image_family must be specified, not both"))
}
}
@ -239,7 +239,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
}
if c.FolderID == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, errors.New("a folder_id must be specified"))
}
@ -249,7 +249,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
for key, file := range c.MetadataFromFile {
if _, err := os.Stat(file); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("cannot access file '%s' with content for value of metadata key '%s': %s", file, key, err))
}
}

View File

@ -10,7 +10,7 @@ import (
"runtime"
"strings"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/shell"
configHelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -67,7 +67,7 @@ func Decode(config *Config, raws ...interface{}) error {
}
func Validate(config *Config) error {
var errs *packer.MultiError
var errs *packersdk.MultiError
if runtime.GOOS == "windows" {
if len(config.ExecuteCommand) == 0 {
@ -112,7 +112,7 @@ func Validate(config *Config) error {
// Verify that the user has given us a command to run
if config.Command == "" && len(config.Inline) == 0 &&
len(config.Scripts) == 0 && config.Script == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
errors.New("Command, Inline, Script and Scripts options cannot all be empty."))
}
@ -123,7 +123,7 @@ func Validate(config *Config) error {
if config.Command != "" {
if len(config.Inline) != 0 || len(config.Scripts) != 0 || config.Script != "" {
errs = packer.MultiErrorAppend(errs, tooManyOptionsErr)
errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr)
} else {
config.Inline = []string{config.Command}
}
@ -131,20 +131,20 @@ func Validate(config *Config) error {
if config.Script != "" {
if len(config.Scripts) > 0 || len(config.Inline) > 0 {
errs = packer.MultiErrorAppend(errs, tooManyOptionsErr)
errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr)
} else {
config.Scripts = []string{config.Script}
}
}
if len(config.Scripts) > 0 && config.Inline != nil {
errs = packer.MultiErrorAppend(errs, tooManyOptionsErr)
errs = packersdk.MultiErrorAppend(errs, tooManyOptionsErr)
}
// Check that all scripts we need to run exist locally
for _, path := range config.Scripts {
if _, err := os.Stat(path); err != nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Bad script '%s': %s", path, err))
}
}
@ -182,7 +182,7 @@ func Validate(config *Config) error {
// Interoperability issues with WSL makes creating and running tempfiles
// via golang's os package basically impossible.
if len(config.Inline) > 0 {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Packer is unable to use the Command and Inline "+
"features with the Windows Linux Subsystem. Please use "+
"the Script or Scripts options instead"))
@ -208,7 +208,7 @@ func Validate(config *Config) error {
for _, kv := range config.Vars {
vs := strings.SplitN(kv, "=", 2)
if len(vs) != 2 || vs[0] == "" {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Environment variable not in format 'key=value': %s", kv))
}
}

View File

@ -412,7 +412,7 @@ PostProcessorRunSeqLoop:
}
if len(errors) > 0 {
err = &MultiError{errors}
err = &packersdk.MultiError{errors}
}
return artifacts, err

View File

@ -130,18 +130,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// Check and render oss_key_name
if err = interpolate.Validate(p.config.OSSKey, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing oss_key_name template: %s", err))
}
errs = packer.MultiErrorAppend(errs, p.config.AlicloudImageTag.CopyOn(&p.config.AlicloudImageTags)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AlicloudImageTag.CopyOn(&p.config.AlicloudImageTags)...)
// Check we have alicloud access variables defined somewhere
errs = packer.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...)
// define all our required parameters
templates := map[string]*string{
@ -150,7 +150,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Check out required params are defined
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}

View File

@ -82,16 +82,16 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p.config.S3Key = "packer-import-{{timestamp}}." + p.config.Format
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// Check and render s3_key_name
if err = interpolate.Validate(p.config.S3Key, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing s3_key_name template: %s", err))
}
// Check we have AWS access variables defined somewhere
errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
// define all our required parameters
templates := map[string]*string{
@ -100,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Check out required params are defined
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}
@ -108,12 +108,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
switch p.config.Format {
case "ova", "raw", "vmdk", "vhd", "vhdx":
default:
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("invalid format '%s'. Only 'ova', 'raw', 'vhd', 'vhdx', or 'vmdk' are allowed", p.config.Format))
}
if p.config.S3Encryption != "" && p.config.S3Encryption != "AES256" && p.config.S3Encryption != "aws:kms" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("invalid s3 encryption format '%s'. Only 'AES256' and 'aws:kms' are allowed", p.config.S3Encryption))
}

View File

@ -67,7 +67,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
if err != nil {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
if p.config.ChecksumTypes == nil {
p.config.ChecksumTypes = []string{"md5"}
@ -75,7 +75,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
for _, k := range p.config.ChecksumTypes {
if h := getHash(k); h == nil {
errs = packer.MultiErrorAppend(errs,
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Unrecognized checksum type: %s", k))
}
}
@ -85,7 +85,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing target template: %s", err))
}

View File

@ -71,7 +71,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// If there is no explicit number of Go threads to use, then set it
if os.Getenv("GOMAXPROCS") == "" {
@ -93,7 +93,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
if err = interpolate.Validate(p.config.OutputPath, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing target template: %s", err))
}

View File

@ -113,10 +113,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p.config.Timeout = 20 * time.Minute
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
if err = interpolate.Validate(p.config.ObjectName, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing space_object_name template: %s", err))
}
@ -130,13 +130,13 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
for key, ptr := range requiredArgs {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}
if len(p.config.ImageRegions) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("image_regions must be set"))
}

View File

@ -89,10 +89,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
"template_description": &p.config.TemplateDescription,
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
for k, v := range requiredArgs {
if *v == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", k))
}
}

View File

@ -82,10 +82,10 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
if len(p.config.Paths) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("paths must be specified"))
}
@ -107,7 +107,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
if p.config.AccountFile != "" && p.config.VaultGCPOauthEngine != "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("May set either account_file or "+
"vault_gcp_oauth_engine, but not both."))
}

View File

@ -100,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// Set defaults
if p.config.GCSObjectName == "" {
@ -109,18 +109,18 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Check and render gcs_object_name
if err = interpolate.Validate(p.config.GCSObjectName, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing gcs_object_name template: %s", err))
}
if p.config.AccountFile != "" {
if p.config.VaultGCPOauthEngine != "" && p.config.ImpersonateServiceAccount != "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("You cannot "+
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("You cannot "+
"specify impersonate_service_account, account_file and vault_gcp_oauth_engine at the same time"))
}
cfg, err := googlecompute.ProcessAccountFile(p.config.AccountFile)
if err != nil {
errs = packer.MultiErrorAppend(errs, err)
errs = packersdk.MultiErrorAppend(errs, err)
}
p.config.account = cfg
}
@ -132,7 +132,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}

View File

@ -106,16 +106,16 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p.config.WaitImageReadyTimeout = ucloudcommon.DefaultCreateImageTimeout
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// Check and render ufile_key_name
if err = interpolate.Validate(p.config.UFileKey, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing ufile_key_name template: %s", err))
}
// Check we have ucloud access variables defined somewhere
errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
// define all our required parameters
templates := map[string]*string{
@ -128,20 +128,20 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Check out required params are defined
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}
imageName := p.config.ImageName
if !ucloudcommon.ImageNamePattern.MatchString(imageName) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("expected %q to be 1-63 characters and only support chinese, english, numbers, '-_,.:[]', got %q", "image_name", imageName))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("expected %q to be 1-63 characters and only support chinese, english, numbers, '-_,.:[]', got %q", "image_name", imageName))
}
switch p.config.Format {
case ImageFileFormatVHD, ImageFileFormatRAW, ImageFileFormatVMDK, ImageFileFormatQCOW2:
default:
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("expected %q only be one of 'raw', 'vhd', 'vmdk', or 'qcow2', got %q", "format", p.config.Format))
}

View File

@ -97,7 +97,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
// Accumulate any errors
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
// Required configuration
templates := map[string]*string{
@ -107,19 +107,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}
if p.config.VagrantCloudUrl == VAGRANT_CLOUD_URL && p.config.AccessToken == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("access_token must be set if vagrant_cloud_url has not been overriden"))
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("access_token must be set if vagrant_cloud_url has not been overriden"))
}
// Create the HTTP client
p.client, err = VagrantCloudClient{}.New(p.config.VagrantCloudUrl, p.config.AccessToken, p.insecureSkipTLSVerify)
if err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Failed to verify authentication token: %v", err))
}

View File

@ -272,11 +272,11 @@ func (p *PostProcessor) configureSingle(c *Config, raws ...interface{}) error {
c.CompressionLevel = flate.DefaultCompression
}
var errs *packer.MultiError
var errs *packersdk.MultiError
if c.VagrantfileTemplate != "" && c.VagrantfileTemplateGenerated == false {
_, err := os.Stat(c.VagrantfileTemplate)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf(
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf(
"vagrantfile_template '%s' does not exist", c.VagrantfileTemplate))
}
}

View File

@ -69,7 +69,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return err
}
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
vc := map[string]*string{
"host": &p.config.Host,
"username": &p.config.Username,
@ -78,19 +78,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
for key, ptr := range vc {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}
if p.config.Folder != "" && !strings.HasPrefix(p.config.Folder, "/") {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Folder must be bound to the root"))
}
sdk, err := url.Parse(fmt.Sprintf("https://%v/sdk", p.config.Host))
if err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error invalid vSphere sdk endpoint: %s", err))
return errs
}

View File

@ -82,14 +82,14 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
// Accumulate any errors
errs := new(packer.MultiError)
errs := new(packersdk.MultiError)
if runtime.GOOS == "windows" {
ovftool = "ovftool.exe"
}
if _, err := exec.LookPath(ovftool); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("ovftool not found: %s", err))
}
@ -105,7 +105,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}

View File

@ -83,19 +83,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
if len(p.config.Paths) == 0 {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("paths must be specified"))
}
// Validate templates in 'paths'
for _, path := range p.config.Paths {
if err = interpolate.Validate(path, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("Error parsing one of 'paths' template: %s", err))
}
}

View File

@ -82,9 +82,9 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
// Accumulate any errors
var errs *packer.MultiError
var errs *packersdk.MultiError
errs = packer.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
errs = packersdk.MultiErrorAppend(errs, p.config.AccessConfig.Prepare(&p.config.ctx)...)
if p.config.FolderID == "" {
p.config.FolderID = os.Getenv("YC_FOLDER_ID")
@ -97,7 +97,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
// Check and render object_name
if err = interpolate.Validate(p.config.ObjectName, &p.config.ctx); err != nil {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("error parsing object_name template: %s", err))
}
@ -110,7 +110,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
for key, ptr := range templates {
if *ptr == "" {
errs = packer.MultiErrorAppend(
errs = packersdk.MultiErrorAppend(
errs, fmt.Errorf("%s must be set", key))
}
}

Some files were not shown because too many files have changed in this diff Show More