Add 'target_image_folder_id' for builder/yandex (#9080)
Add 'target_image_folder_id' for builder/yandex Closes #9079
This commit is contained in:
parent
5d2fee04b2
commit
1155ab8e3c
|
@ -16,6 +16,8 @@
|
|||
* provisioner/powershell: Add cleanup step to remove temporarily created
|
||||
scripts; cleanup can be skipped by setting the `skip_clean` option
|
||||
[GH-8908]
|
||||
* builder/yandex: Allow set `target_image_folder_id ` where save built
|
||||
image in [GH-9079]
|
||||
|
||||
### Bug Fixes:
|
||||
* builder/amazon: Fix bug with launch_block_device_mappings in spot instances.
|
||||
|
|
|
@ -36,6 +36,8 @@ type Config struct {
|
|||
Endpoint string `mapstructure:"endpoint" required:"false"`
|
||||
// The folder ID that will be used to launch instances and store images.
|
||||
// Alternatively you may set value by environment variable YC_FOLDER_ID.
|
||||
// To use a different folder for looking up the source image or saving the target image to
|
||||
// check options 'source_image_folder_id' and 'target_image_folder_id'.
|
||||
FolderID string `mapstructure:"folder_id" required:"true"`
|
||||
// Path to file with Service Account key in json format. This
|
||||
// is an alternative method to authenticate to Yandex.Cloud. Alternatively you may set environment variable
|
||||
|
@ -104,6 +106,9 @@ type Config struct {
|
|||
// the launched instance. Note, the zone of the subnet must match the
|
||||
// zone in which the VM is launched.
|
||||
SubnetID string `mapstructure:"subnet_id" required:"false"`
|
||||
// The ID of the folder to save built image in.
|
||||
// This defaults to value of 'folder_id'.
|
||||
TargetImageFolderID string `mapstructure:"target_image_folder_id" required:"false"`
|
||||
// If set to true, then launched instance will have external internet
|
||||
// access.
|
||||
UseIPv4Nat bool `mapstructure:"use_ipv4_nat" required:"false"`
|
||||
|
@ -274,6 +279,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||
errs, errors.New("a folder_id must be specified"))
|
||||
}
|
||||
|
||||
if c.TargetImageFolderID == "" {
|
||||
c.TargetImageFolderID = c.FolderID
|
||||
}
|
||||
|
||||
for key, file := range c.MetadataFromFile {
|
||||
if _, err := os.Stat(file); err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
|
|
|
@ -86,6 +86,7 @@ type FlatConfig struct {
|
|||
SourceImageID *string `mapstructure:"source_image_id" required:"false" cty:"source_image_id"`
|
||||
SourceImageName *string `mapstructure:"source_image_name" cty:"source_image_name"`
|
||||
SubnetID *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||
TargetImageFolderID *string `mapstructure:"target_image_folder_id" required:"false" cty:"target_image_folder_id"`
|
||||
UseIPv4Nat *bool `mapstructure:"use_ipv4_nat" required:"false" cty:"use_ipv4_nat"`
|
||||
UseIPv6 *bool `mapstructure:"use_ipv6" required:"false" cty:"use_ipv6"`
|
||||
UseInternalIP *bool `mapstructure:"use_internal_ip" required:"false" cty:"use_internal_ip"`
|
||||
|
@ -182,6 +183,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||
"source_image_id": &hcldec.AttrSpec{Name: "source_image_id", Type: cty.String, Required: false},
|
||||
"source_image_name": &hcldec.AttrSpec{Name: "source_image_name", Type: cty.String, Required: false},
|
||||
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
||||
"target_image_folder_id": &hcldec.AttrSpec{Name: "target_image_folder_id", Type: cty.String, Required: false},
|
||||
"use_ipv4_nat": &hcldec.AttrSpec{Name: "use_ipv4_nat", Type: cty.Bool, Required: false},
|
||||
"use_ipv6": &hcldec.AttrSpec{Name: "use_ipv6", Type: cty.Bool, Required: false},
|
||||
"use_internal_ip": &hcldec.AttrSpec{Name: "use_internal_ip", Type: cty.Bool, Required: false},
|
||||
|
|
|
@ -180,6 +180,11 @@ func TestConfigDefaults(t *testing.T) {
|
|||
func(c *Config) interface{} { return c.Communicator.SSHPort },
|
||||
22,
|
||||
},
|
||||
|
||||
{
|
||||
func(c *Config) interface{} { return c.TargetImageFolderID },
|
||||
"hashicorp",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
|
|
@ -26,7 +26,7 @@ func (stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multis
|
|||
defer cancel()
|
||||
|
||||
op, err := sdk.WrapOperation(sdk.Compute().Image().Create(ctx, &compute.CreateImageRequest{
|
||||
FolderId: c.FolderID,
|
||||
FolderId: c.TargetImageFolderID,
|
||||
Name: c.ImageName,
|
||||
Family: c.ImageFamily,
|
||||
Description: c.ImageDescription,
|
||||
|
|
|
@ -62,6 +62,9 @@
|
|||
the launched instance. Note, the zone of the subnet must match the
|
||||
zone in which the VM is launched.
|
||||
|
||||
- `target_image_folder_id` (string) - The ID of the folder to save built image in.
|
||||
This defaults to value of 'folder_id'.
|
||||
|
||||
- `use_ipv4_nat` (bool) - If set to true, then launched instance will have external internet
|
||||
access.
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
- `folder_id` (string) - The folder ID that will be used to launch instances and store images.
|
||||
Alternatively you may set value by environment variable YC_FOLDER_ID.
|
||||
To use a different folder for looking up the source image or saving the target image to
|
||||
check options 'source_image_folder_id' and 'target_image_folder_id'.
|
||||
|
||||
- `token` (string) - OAuth token to use to authenticate to Yandex.Cloud. Alternatively you may set
|
||||
value by environment variable YC_TOKEN.
|
||||
|
|
Loading…
Reference in New Issue