diff --git a/builder/yandex/common_config.go b/builder/yandex/common_config.go index 992f5c022..bec224a3a 100644 --- a/builder/yandex/common_config.go +++ b/builder/yandex/common_config.go @@ -8,7 +8,7 @@ import ( "os" "regexp" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) @@ -32,11 +32,11 @@ type CommonConfig struct { CloudConfig `mapstructure:",squash"` } -func (c *CommonConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *CommonConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { 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)) } } @@ -57,13 +57,13 @@ type CloudConfig struct { FolderID string `mapstructure:"folder_id" required:"true"` } -func (c *CloudConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *CloudConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { if c.FolderID == "" { c.FolderID = os.Getenv("YC_FOLDER_ID") } if c.FolderID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, errors.New("a folder_id must be specified")) } return errs @@ -81,7 +81,7 @@ type DiskConfig struct { DiskLabels map[string]string `mapstructure:"disk_labels" required:"false"` } -func (c *DiskConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *DiskConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { if c.DiskSizeGb == 0 { c.DiskSizeGb = 10 @@ -115,7 +115,7 @@ type NetworkConfig struct { UseInternalIP bool `mapstructure:"use_internal_ip" required:"false"` } -func (c *NetworkConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *NetworkConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { if c.Zone == "" { c.Zone = defaultZone } @@ -141,16 +141,16 @@ type ImageConfig struct { ImageProductIDs []string `mapstructure:"image_product_ids" required:"false"` } -func (c *ImageConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *ImageConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { 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")) @@ -164,7 +164,7 @@ func (c *ImageConfig) Prepare(errs *packer.MultiError) *packer.MultiError { 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 @@ -196,7 +196,7 @@ type InstanceConfig struct { Preemptible bool `mapstructure:"preemptible"` } -func (c *InstanceConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *InstanceConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { if c.InstanceCores == 0 { c.InstanceCores = 2 } @@ -211,7 +211,7 @@ func (c *InstanceConfig) Prepare(errs *packer.MultiError) *packer.MultiError { 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)) } } diff --git a/builder/yandex/util.go b/builder/yandex/util.go index 24ccc6c74..fbe74ec3e 100644 --- a/builder/yandex/util.go +++ b/builder/yandex/util.go @@ -29,7 +29,7 @@ func toBytes(gigabytesCount int) int64 { func writeSerialLogFile(ctx context.Context, state multistep.StateBag, serialLogFile string) error { sdk := state.Get("sdk").(*ycsdk.SDK) - ui := state.Get("ui").(packer.Ui) + ui := state.Get("ui").(packersdk.Ui) instanceID := state.Get("instance_id").(string) if instanceID == "" { diff --git a/post-processor/yandex-export/config.go b/post-processor/yandex-export/config.go index febb6faf1..ce71f1ba2 100644 --- a/post-processor/yandex-export/config.go +++ b/post-processor/yandex-export/config.go @@ -4,7 +4,7 @@ package yandexexport import ( "fmt" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type ExchangeConfig struct { @@ -13,9 +13,9 @@ type ExchangeConfig struct { ServiceAccountID string `mapstructure:"service_account_id" required:"true"` } -func (c *ExchangeConfig) Prepare(errs *packer.MultiError) *packer.MultiError { +func (c *ExchangeConfig) Prepare(errs *packersdk.MultiError) *packersdk.MultiError { if c.ServiceAccountID == "" { - errs = packer.MultiErrorAppend( + errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("service_account_id must be specified")) } diff --git a/post-processor/yandex-import/post-processor.go b/post-processor/yandex-import/post-processor.go index f24cf014d..9d6b796f4 100644 --- a/post-processor/yandex-import/post-processor.go +++ b/post-processor/yandex-import/post-processor.go @@ -69,7 +69,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { // Accumulate any errors 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)...) errs = p.config.CloudConfig.Prepare(errs) errs = p.config.ImageConfig.Prepare(errs) errs = p.config.ExchangeConfig.Prepare(errs) diff --git a/post-processor/yandex-import/utils.go b/post-processor/yandex-import/utils.go index 832367e46..40eb874de 100644 --- a/post-processor/yandex-import/utils.go +++ b/post-processor/yandex-import/utils.go @@ -66,7 +66,7 @@ func uploadToBucket(s3conn *s3.S3, ui packersdk.Ui, artifact packersdk.Artifact, }, nil } -func createYCImage(ctx context.Context, driver yandex.Driver, ui packer.Ui, imageSrc cloudImageSource, c *Config) (*compute.Image, error) { +func createYCImage(ctx context.Context, driver yandex.Driver, ui packersdk.Ui, imageSrc cloudImageSource, c *Config) (*compute.Image, error) { req := &compute.CreateImageRequest{ FolderId: c.CloudConfig.FolderID, Name: c.ImageConfig.ImageName,