Rename config key name
This commit is contained in:
parent
9c565a97c0
commit
03a0bf26f2
|
@ -64,7 +64,7 @@ type Config struct {
|
|||
ImageLabels map[string]string `mapstructure:"image_labels" required:"false"`
|
||||
// Minimum size of the disk that will be created from built image, specified in gigabytes.
|
||||
// Should be more or equal to `disk_size_gb`.
|
||||
ImageMinDiskSize int `mapstructure:"image_min_disk_size" required:"false"`
|
||||
ImageMinDiskSizeGb int `mapstructure:"image_min_disk_size_gb" required:"false"`
|
||||
// The unique name of the resulting image. Defaults to
|
||||
// `packer-{{timestamp}}`.
|
||||
ImageName string `mapstructure:"image_name" required:"false"`
|
||||
|
@ -167,14 +167,14 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||
c.DiskType = "network-hdd"
|
||||
}
|
||||
|
||||
if c.ImageMinDiskSize == 0 {
|
||||
c.ImageMinDiskSize = c.DiskSizeGb
|
||||
if c.ImageMinDiskSizeGb == 0 {
|
||||
c.ImageMinDiskSizeGb = c.DiskSizeGb
|
||||
}
|
||||
|
||||
if c.ImageMinDiskSize <= c.DiskSizeGb {
|
||||
if c.ImageMinDiskSizeGb < c.DiskSizeGb {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("Invalid image_min_disk_size value (%d): Must be equal or greate than disk_size_gb (%d)",
|
||||
c.ImageMinDiskSize, c.DiskSizeGb))
|
||||
c.ImageMinDiskSizeGb, c.DiskSizeGb))
|
||||
}
|
||||
|
||||
if c.ImageDescription == "" {
|
||||
|
|
|
@ -73,7 +73,7 @@ type FlatConfig struct {
|
|||
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"`
|
||||
ImageMinDiskSize *int `mapstructure:"image_min_disk_size" required:"false" cty:"image_min_disk_size" hcl:"image_min_disk_size"`
|
||||
ImageMinDiskSizeGb *int `mapstructure:"image_min_disk_size_gb" required:"false" cty:"image_min_disk_size_gb" hcl:"image_min_disk_size_gb"`
|
||||
ImageName *string `mapstructure:"image_name" required:"false" cty:"image_name" hcl:"image_name"`
|
||||
ImageProductIDs []string `mapstructure:"image_product_ids" required:"false" cty:"image_product_ids" hcl:"image_product_ids"`
|
||||
InstanceCores *int `mapstructure:"instance_cores" required:"false" cty:"instance_cores" hcl:"instance_cores"`
|
||||
|
@ -176,7 +176,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||
"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},
|
||||
"image_min_disk_size": &hcldec.AttrSpec{Name: "image_min_disk_size", Type: cty.Number, Required: false},
|
||||
"image_min_disk_size_gb": &hcldec.AttrSpec{Name: "image_min_disk_size_gb", Type: cty.Number, Required: false},
|
||||
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
|
||||
"image_product_ids": &hcldec.AttrSpec{Name: "image_product_ids", Type: cty.List(cty.String), Required: false},
|
||||
"instance_cores": &hcldec.AttrSpec{Name: "instance_cores", Type: cty.Number, Required: false},
|
||||
|
|
|
@ -175,14 +175,14 @@ func TestConfigImageMinDiskSize(t *testing.T) {
|
|||
{
|
||||
Name: "image_min_disk_size lower than disk_size (default value)",
|
||||
Config: map[string]interface{}{
|
||||
"image_min_disk_size": 2,
|
||||
"image_min_disk_size_gb": 2,
|
||||
},
|
||||
Err: true,
|
||||
},
|
||||
{
|
||||
Name: "image_min_disk_size greater than disk_size (default value)",
|
||||
Config: map[string]interface{}{
|
||||
"image_min_disk_size": 20,
|
||||
"image_min_disk_size_gb": 20,
|
||||
},
|
||||
Err: false,
|
||||
},
|
||||
|
@ -190,7 +190,7 @@ func TestConfigImageMinDiskSize(t *testing.T) {
|
|||
Name: "image_min_disk_size lower than disk_size (custom value)",
|
||||
Config: map[string]interface{}{
|
||||
"disk_size_gb": 50,
|
||||
"image_min_disk_size": 20,
|
||||
"image_min_disk_size_gb": 20,
|
||||
},
|
||||
Err: true,
|
||||
},
|
||||
|
@ -198,7 +198,7 @@ func TestConfigImageMinDiskSize(t *testing.T) {
|
|||
Name: "image_min_disk_size greate than disk_size (custom value)",
|
||||
Config: map[string]interface{}{
|
||||
"disk_size_gb": 50,
|
||||
"image_min_disk_size": 55,
|
||||
"image_min_disk_size_gb": 55,
|
||||
},
|
||||
Err: false,
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
Family: c.ImageFamily,
|
||||
Description: c.ImageDescription,
|
||||
Labels: c.ImageLabels,
|
||||
MinDiskSize: toBytes(c.ImageMinDiskSize),
|
||||
MinDiskSize: toBytes(c.ImageMinDiskSizeGb),
|
||||
ProductIds: c.ImageProductIDs,
|
||||
Source: &compute.CreateImageRequest_DiskId{
|
||||
DiskId: diskID,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
- `image_labels` (map[string]string) - Key/value pair labels to
|
||||
apply to the created image.
|
||||
|
||||
- `image_min_disk_size` (int) - Minimum size of the disk that will be created from built image, specified in gigabytes.
|
||||
- `image_min_disk_size_gb` (int) - Minimum size of the disk that will be created from built image, specified in gigabytes.
|
||||
Should be more or equal to `disk_size_gb`.
|
||||
|
||||
- `image_name` (string) - The unique name of the resulting image. Defaults to
|
||||
|
|
Loading…
Reference in New Issue