From 3f13c6eed9407f081fb84bf27337a9e93694fc70 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Thu, 9 Jan 2020 01:02:41 +0000 Subject: [PATCH] Add default_if_empty to google_compute_router_nat defaults Signed-off-by: Modular Magician --- google/resource_compute_router_nat.go | 28 ++++++++------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/google/resource_compute_router_nat.go b/google/resource_compute_router_nat.go index fa8c82a4306..22956cbb7ff 100644 --- a/google/resource_compute_router_nat.go +++ b/google/resource_compute_router_nat.go @@ -721,41 +721,29 @@ func flattenComputeRouterNatMinPortsPerVm(v interface{}, d *schema.ResourceData) } func flattenComputeRouterNatUdpIdleTimeoutSec(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. + if v == nil || v.(string) == "" { + return 30 } return v } func flattenComputeRouterNatIcmpIdleTimeoutSec(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. + if v == nil || v.(string) == "" { + return 30 } return v } func flattenComputeRouterNatTcpEstablishedIdleTimeoutSec(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. + if v == nil || v.(string) == "" { + return 1200 } return v } func flattenComputeRouterNatTcpTransitoryIdleTimeoutSec(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. + if v == nil || v.(string) == "" { + return 30 } return v }