add labels for temp disk

This commit is contained in:
Roman Mingazeev 2020-11-13 16:35:48 +03:00
parent fe9dca4c75
commit 6a327b1330
4 changed files with 7 additions and 0 deletions

View File

@ -44,6 +44,8 @@ type Config struct {
DiskSizeGb int `mapstructure:"disk_size_gb" required:"false"`
// Specify disk type for the launched instance. Defaults to `network-hdd`.
DiskType string `mapstructure:"disk_type" required:"false"`
// Key/value pair labels to apply to the temporary disk.
DiskLabels map[string]string `mapstructure:"disk_labels" required:"false"`
// The description of the resulting image.
ImageDescription string `mapstructure:"image_description" required:"false"`
// The family name of the resulting image.

View File

@ -74,6 +74,7 @@ type FlatConfig struct {
DiskName *string `mapstructure:"disk_name" required:"false" cty:"disk_name" hcl:"disk_name"`
DiskSizeGb *int `mapstructure:"disk_size_gb" required:"false" cty:"disk_size_gb" hcl:"disk_size_gb"`
DiskType *string `mapstructure:"disk_type" required:"false" cty:"disk_type" hcl:"disk_type"`
DiskLabels map[string]string `mapstructure:"disk_labels" required:"false" cty:"disk_labels" hcl:"disk_labels"`
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description" hcl:"image_description"`
ImageFamily *string `mapstructure:"image_family" required:"false" cty:"image_family" hcl:"image_family"`
ImageLabels map[string]string `mapstructure:"image_labels" required:"false" cty:"image_labels" hcl:"image_labels"`
@ -180,6 +181,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"disk_name": &hcldec.AttrSpec{Name: "disk_name", Type: cty.String, Required: false},
"disk_size_gb": &hcldec.AttrSpec{Name: "disk_size_gb", Type: cty.Number, Required: false},
"disk_type": &hcldec.AttrSpec{Name: "disk_type", Type: cty.String, Required: false},
"disk_labels": &hcldec.AttrSpec{Name: "disk_labels", Type: cty.Map(cty.String), Required: false},
"image_description": &hcldec.AttrSpec{Name: "image_description", Type: cty.String, Required: false},
"image_family": &hcldec.AttrSpec{Name: "image_family", Type: cty.String, Required: false},
"image_labels": &hcldec.AttrSpec{Name: "image_labels", Type: cty.Map(cty.String), Required: false},

View File

@ -61,6 +61,7 @@ func createDisk(ctx context.Context, c *Config, d Driver, sourceImage *Image) (*
Name: c.DiskName,
FolderId: c.FolderID,
TypeId: c.DiskType,
Labels: c.DiskLabels,
ZoneId: c.Zone,
Size: int64((datasize.ByteSize(c.DiskSizeGb) * datasize.GB).Bytes()),
Source: &compute.CreateDiskRequest_ImageId{

View File

@ -9,6 +9,8 @@
- `disk_type` (string) - Specify disk type for the launched instance. Defaults to `network-hdd`.
- `disk_labels` (map[string]string) - Key/value pair labels to apply to the temporary disk.
- `image_description` (string) - The description of the resulting image.
- `image_family` (string) - The family name of the resulting image.