Skip to content

Commit ee4d6d7

Browse files
Updated datatype for mtu (#4601) (#3075)
Signed-off-by: Modular Magician <[email protected]>
1 parent 923b0c0 commit ee4d6d7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.changelog/4601.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: fixed datatype for `mtu` in `google_compute_interconnect_attachment`
3+
```

google-beta/resource_compute_interconnect_attachment.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ traffic will traverse through. Required if type is DEDICATED, must not
145145
be set if type is PARTNER.`,
146146
},
147147
"mtu": {
148-
Type: schema.TypeString,
148+
Type: schema.TypeInt,
149149
Computed: true,
150150
Optional: true,
151151
Description: `Maximum Transmission Unit (MTU), in bytes, of packets passing through
@@ -645,7 +645,20 @@ func flattenComputeInterconnectAttachmentDescription(v interface{}, d *schema.Re
645645
}
646646

647647
func flattenComputeInterconnectAttachmentMtu(v interface{}, d *schema.ResourceData, config *Config) interface{} {
648-
return v
648+
// Handles the string fixed64 format
649+
if strVal, ok := v.(string); ok {
650+
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
651+
return intVal
652+
}
653+
}
654+
655+
// number values are represented as float64
656+
if floatVal, ok := v.(float64); ok {
657+
intVal := int(floatVal)
658+
return intVal
659+
}
660+
661+
return v // let terraform core handle it otherwise
649662
}
650663

651664
func flattenComputeInterconnectAttachmentBandwidth(v interface{}, d *schema.ResourceData, config *Config) interface{} {

google-beta/resource_dataproc_cluster_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1414
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1515

16-
dataproc "google.golang.org/api/dataproc/v1beta2"
1716
"google.golang.org/api/googleapi"
17+
18+
dataproc "google.golang.org/api/dataproc/v1beta2"
1819
)
1920

2021
func TestDataprocExtractInitTimeout(t *testing.T) {

0 commit comments

Comments
 (0)