mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-06-29 06:42:36 +00:00
Terraform: Support for (Regional)Disk physicalBlockSizeBytes (#3237)
<!-- This change is generated by MagicModules. --> /cc @drebes
This commit is contained in:
parent
6aabf31847
commit
0bb8257361
|
@ -299,6 +299,12 @@ func resourceComputeDisk() *schema.Resource {
|
|||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"physical_block_size_bytes": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
@ -467,6 +473,12 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
} else if v, ok := d.GetOkExists("size"); !isEmptyValue(reflect.ValueOf(sizeGbProp)) && (ok || !reflect.DeepEqual(v, sizeGbProp)) {
|
||||
obj["sizeGb"] = sizeGbProp
|
||||
}
|
||||
physicalBlockSizeBytesProp, err := expandComputeDiskPhysicalBlockSizeBytes(d.Get("physical_block_size_bytes"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("physical_block_size_bytes"); !isEmptyValue(reflect.ValueOf(physicalBlockSizeBytesProp)) && (ok || !reflect.DeepEqual(v, physicalBlockSizeBytesProp)) {
|
||||
obj["physicalBlockSizeBytes"] = physicalBlockSizeBytesProp
|
||||
}
|
||||
typeProp, err := expandComputeDiskType(d.Get("type"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -611,6 +623,9 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
|
|||
if err := d.Set("users", flattenComputeDiskUsers(res["users"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading Disk: %s", err)
|
||||
}
|
||||
if err := d.Set("physical_block_size_bytes", flattenComputeDiskPhysicalBlockSizeBytes(res["physicalBlockSizeBytes"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading Disk: %s", err)
|
||||
}
|
||||
if err := d.Set("type", flattenComputeDiskType(res["type"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading Disk: %s", err)
|
||||
}
|
||||
|
@ -893,6 +908,16 @@ func flattenComputeDiskUsers(v interface{}, d *schema.ResourceData) interface{}
|
|||
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
|
||||
}
|
||||
|
||||
func flattenComputeDiskPhysicalBlockSizeBytes(v interface{}, d *schema.ResourceData) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeDiskType(v interface{}, d *schema.ResourceData) interface{} {
|
||||
if v == nil {
|
||||
return v
|
||||
|
@ -1040,6 +1065,10 @@ func expandComputeDiskSize(v interface{}, d TerraformResourceData, config *Confi
|
|||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeDiskPhysicalBlockSizeBytes(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeDiskType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
f, err := parseZonalFieldValue("diskTypes", v.(string), "project", "zone", d, config, true)
|
||||
if err != nil {
|
||||
|
|
|
@ -58,6 +58,7 @@ resource "google_compute_disk" "default" {
|
|||
labels = {
|
||||
environment = "dev"
|
||||
}
|
||||
physical_block_size_bytes = 4096
|
||||
}
|
||||
`, context)
|
||||
}
|
||||
|
|
|
@ -94,6 +94,12 @@ func resourceComputeRegionDisk() *schema.Resource {
|
|||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"physical_block_size_bytes": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"region": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -214,6 +220,12 @@ func resourceComputeRegionDiskCreate(d *schema.ResourceData, meta interface{}) e
|
|||
} else if v, ok := d.GetOkExists("size"); !isEmptyValue(reflect.ValueOf(sizeGbProp)) && (ok || !reflect.DeepEqual(v, sizeGbProp)) {
|
||||
obj["sizeGb"] = sizeGbProp
|
||||
}
|
||||
physicalBlockSizeBytesProp, err := expandComputeRegionDiskPhysicalBlockSizeBytes(d.Get("physical_block_size_bytes"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("physical_block_size_bytes"); !isEmptyValue(reflect.ValueOf(physicalBlockSizeBytesProp)) && (ok || !reflect.DeepEqual(v, physicalBlockSizeBytesProp)) {
|
||||
obj["physicalBlockSizeBytes"] = physicalBlockSizeBytesProp
|
||||
}
|
||||
replicaZonesProp, err := expandComputeRegionDiskReplicaZones(d.Get("replica_zones"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -352,6 +364,9 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
|
|||
if err := d.Set("users", flattenComputeRegionDiskUsers(res["users"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading RegionDisk: %s", err)
|
||||
}
|
||||
if err := d.Set("physical_block_size_bytes", flattenComputeRegionDiskPhysicalBlockSizeBytes(res["physicalBlockSizeBytes"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading RegionDisk: %s", err)
|
||||
}
|
||||
if err := d.Set("replica_zones", flattenComputeRegionDiskReplicaZones(res["replicaZones"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading RegionDisk: %s", err)
|
||||
}
|
||||
|
@ -628,6 +643,16 @@ func flattenComputeRegionDiskUsers(v interface{}, d *schema.ResourceData) interf
|
|||
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
|
||||
}
|
||||
|
||||
func flattenComputeRegionDiskPhysicalBlockSizeBytes(v interface{}, d *schema.ResourceData) interface{} {
|
||||
// Handles the string fixed64 format
|
||||
if strVal, ok := v.(string); ok {
|
||||
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
||||
return intVal
|
||||
} // let terraform core handle it if we can't convert the string to an int.
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeRegionDiskReplicaZones(v interface{}, d *schema.ResourceData) interface{} {
|
||||
if v == nil {
|
||||
return v
|
||||
|
@ -733,6 +758,10 @@ func expandComputeRegionDiskSize(v interface{}, d TerraformResourceData, config
|
|||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeRegionDiskPhysicalBlockSizeBytes(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeRegionDiskReplicaZones(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
l := v.([]interface{})
|
||||
req := make([]interface{}, 0, len(l))
|
||||
|
|
|
@ -55,6 +55,7 @@ resource "google_compute_region_disk" "regiondisk" {
|
|||
snapshot = "${google_compute_snapshot.snapdisk.self_link}"
|
||||
type = "pd-ssd"
|
||||
region = "us-central1"
|
||||
physical_block_size_bytes = 4096
|
||||
|
||||
replica_zones = ["us-central1-a", "us-central1-f"]
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ resource "google_compute_disk" "default" {
|
|||
labels = {
|
||||
environment = "dev"
|
||||
}
|
||||
physical_block_size_bytes = 4096
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -107,6 +108,14 @@ The following arguments are supported:
|
|||
the value of sizeGb must not be less than the size of the sourceImage
|
||||
or the size of the snapshot.
|
||||
|
||||
* `physical_block_size_bytes` -
|
||||
(Optional)
|
||||
Physical block size of the persistent disk, in bytes. If not present
|
||||
in a request, a default value is used. Currently supported sizes
|
||||
are 4096 and 16384, other sizes may be added in the future.
|
||||
If an unsupported value is requested, the error message will list
|
||||
the supported values for the caller's project.
|
||||
|
||||
* `type` -
|
||||
(Optional)
|
||||
URL of the disk type resource describing which disk type to use to
|
||||
|
|
|
@ -63,6 +63,7 @@ resource "google_compute_region_disk" "regiondisk" {
|
|||
snapshot = "${google_compute_snapshot.snapdisk.self_link}"
|
||||
type = "pd-ssd"
|
||||
region = "us-central1"
|
||||
physical_block_size_bytes = 4096
|
||||
|
||||
replica_zones = ["us-central1-a", "us-central1-f"]
|
||||
}
|
||||
|
@ -124,6 +125,14 @@ The following arguments are supported:
|
|||
the value of sizeGb must not be less than the size of the sourceImage
|
||||
or the size of the snapshot.
|
||||
|
||||
* `physical_block_size_bytes` -
|
||||
(Optional)
|
||||
Physical block size of the persistent disk, in bytes. If not present
|
||||
in a request, a default value is used. Currently supported sizes
|
||||
are 4096 and 16384, other sizes may be added in the future.
|
||||
If an unsupported value is requested, the error message will list
|
||||
the supported values for the caller's project.
|
||||
|
||||
* `type` -
|
||||
(Optional)
|
||||
URL of the disk type resource describing which disk type to use to
|
||||
|
|
Loading…
Reference in New Issue
Block a user