Skip to content

Commit

Permalink
Fix region disk type (#1890)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @danawillow
  • Loading branch information
modular-magician authored and danawillow committed Aug 16, 2018
1 parent 81420a2 commit 085a05c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions google/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
if err := d.Set("size", flattenComputeDiskSize(res["sizeGb"])); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}
if err := d.Set("type", flattenComputeDiskType(res["type"])); err != nil {
if err := d.Set("users", flattenComputeDiskUsers(res["users"])); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}
if err := d.Set("users", flattenComputeDiskUsers(res["users"])); err != nil {
if err := d.Set("type", flattenComputeDiskType(res["type"])); err != nil {
return fmt.Errorf("Error reading Disk: %s", err)
}
if err := d.Set("image", flattenComputeDiskImage(res["sourceImage"])); err != nil {
Expand Down Expand Up @@ -895,18 +895,18 @@ func flattenComputeDiskSize(v interface{}) interface{} {
return v
}

func flattenComputeDiskType(v interface{}) interface{} {
func flattenComputeDiskUsers(v interface{}) interface{} {
if v == nil {
return v
}
return NameFromSelfLinkStateFunc(v)
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
}

func flattenComputeDiskUsers(v interface{}) interface{} {
func flattenComputeDiskType(v interface{}) interface{} {
if v == nil {
return v
}
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
return NameFromSelfLinkStateFunc(v)
}

func flattenComputeDiskImage(v interface{}) interface{} {
Expand Down
44 changes: 22 additions & 22 deletions google/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ 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
}
typeProp, err := expandComputeRegionDiskType(d.Get("type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
replicaZonesProp, err := expandComputeRegionDiskReplicaZones(d.Get("replica_zones"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("replica_zones"); !isEmptyValue(reflect.ValueOf(replicaZonesProp)) && (ok || !reflect.DeepEqual(v, replicaZonesProp)) {
obj["replicaZones"] = replicaZonesProp
}
typeProp, err := expandComputeRegionDiskType(d.Get("type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
regionProp, err := expandComputeRegionDiskRegion(d.Get("region"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -334,15 +334,15 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("size", flattenComputeRegionDiskSize(res["sizeGb"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
if err := d.Set("type", flattenComputeRegionDiskType(res["type"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
if err := d.Set("users", flattenComputeRegionDiskUsers(res["users"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
if err := d.Set("replica_zones", flattenComputeRegionDiskReplicaZones(res["replicaZones"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
if err := d.Set("type", flattenComputeRegionDiskType(res["type"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
if err := d.Set("region", flattenComputeRegionDiskRegion(res["region"])); err != nil {
return fmt.Errorf("Error reading RegionDisk: %s", err)
}
Expand Down Expand Up @@ -600,25 +600,25 @@ func flattenComputeRegionDiskSize(v interface{}) interface{} {
return v
}

func flattenComputeRegionDiskType(v interface{}) interface{} {
func flattenComputeRegionDiskUsers(v interface{}) interface{} {
if v == nil {
return v
}
return NameFromSelfLinkStateFunc(v)
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
}

func flattenComputeRegionDiskUsers(v interface{}) interface{} {
func flattenComputeRegionDiskReplicaZones(v interface{}) interface{} {
if v == nil {
return v
}
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
}

func flattenComputeRegionDiskReplicaZones(v interface{}) interface{} {
func flattenComputeRegionDiskType(v interface{}) interface{} {
if v == nil {
return v
}
return convertAndMapStringArr(v.([]interface{}), ConvertSelfLinkToV1)
return NameFromSelfLinkStateFunc(v)
}

func flattenComputeRegionDiskRegion(v interface{}) interface{} {
Expand Down Expand Up @@ -702,14 +702,6 @@ func expandComputeRegionDiskSize(v interface{}, d *schema.ResourceData, config *
return v, nil
}

func expandComputeRegionDiskType(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
f, err := parseZonalFieldValue("diskTypes", v.(string), "project", "zone", d, config, true)
if err != nil {
return nil, fmt.Errorf("Invalid value for type: %s", err)
}
return f.RelativeLink(), nil
}

func expandComputeRegionDiskReplicaZones(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
Expand All @@ -723,6 +715,14 @@ func expandComputeRegionDiskReplicaZones(v interface{}, d *schema.ResourceData,
return req, nil
}

func expandComputeRegionDiskType(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
f, err := parseRegionalFieldValue("diskTypes", v.(string), "project", "region", "zone", d, config, true)
if err != nil {
return nil, fmt.Errorf("Invalid value for type: %s", err)
}
return f.RelativeLink(), nil
}

func expandComputeRegionDiskRegion(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
if err != nil {
Expand Down

0 comments on commit 085a05c

Please sign in to comment.