From d6e23fe30024dd91c25469f11ad5421bb475af52 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Thu, 9 Jan 2020 01:38:21 +0000 Subject: [PATCH] Add default_if_empty to google_compute_router_nat defaults Signed-off-by: Modular Magician --- ...source_access_context_manager_access_level.go | 3 ++- ...e_access_context_manager_service_perimeter.go | 3 ++- google/resource_compute_address.go | 3 ++- google/resource_compute_router_nat.go | 16 ++++++++++++++++ google/resource_compute_target_https_proxy.go | 3 ++- google/resource_dns_managed_zone.go | 3 ++- google/resource_logging_metric.go | 3 ++- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/google/resource_access_context_manager_access_level.go b/google/resource_access_context_manager_access_level.go index 0594dc0ad95..dfc2496102b 100644 --- a/google/resource_access_context_manager_access_level.go +++ b/google/resource_access_context_manager_access_level.go @@ -462,9 +462,10 @@ func flattenAccessContextManagerAccessLevelBasic(v interface{}, d *schema.Resour return []interface{}{transformed} } func flattenAccessContextManagerAccessLevelBasicCombiningFunction(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "AND" } + return v } diff --git a/google/resource_access_context_manager_service_perimeter.go b/google/resource_access_context_manager_service_perimeter.go index 9f91c189d9a..990630d4e03 100644 --- a/google/resource_access_context_manager_service_perimeter.go +++ b/google/resource_access_context_manager_service_perimeter.go @@ -407,9 +407,10 @@ func flattenAccessContextManagerServicePerimeterUpdateTime(v interface{}, d *sch } func flattenAccessContextManagerServicePerimeterPerimeterType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "PERIMETER_TYPE_REGULAR" } + return v } diff --git a/google/resource_compute_address.go b/google/resource_compute_address.go index d627d470946..e8a831e1300 100644 --- a/google/resource_compute_address.go +++ b/google/resource_compute_address.go @@ -353,9 +353,10 @@ func flattenComputeAddressAddress(v interface{}, d *schema.ResourceData) interfa } func flattenComputeAddressAddressType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "EXTERNAL" } + return v } diff --git a/google/resource_compute_router_nat.go b/google/resource_compute_router_nat.go index fa8c82a4306..dd5c3d07275 100644 --- a/google/resource_compute_router_nat.go +++ b/google/resource_compute_router_nat.go @@ -721,42 +721,58 @@ func flattenComputeRouterNatMinPortsPerVm(v interface{}, d *schema.ResourceData) } func flattenComputeRouterNatUdpIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // 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 flattenComputeRouterNatIcmpIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // 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 flattenComputeRouterNatTcpEstablishedIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 1200 + } // 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 flattenComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // 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 } diff --git a/google/resource_compute_target_https_proxy.go b/google/resource_compute_target_https_proxy.go index 241e571c3f3..3b7777f6b2e 100644 --- a/google/resource_compute_target_https_proxy.go +++ b/google/resource_compute_target_https_proxy.go @@ -457,9 +457,10 @@ func flattenComputeTargetHttpsProxyName(v interface{}, d *schema.ResourceData) i } func flattenComputeTargetHttpsProxyQuicOverride(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "NONE" } + return v } diff --git a/google/resource_dns_managed_zone.go b/google/resource_dns_managed_zone.go index 67473e8a7f1..0a937382f63 100644 --- a/google/resource_dns_managed_zone.go +++ b/google/resource_dns_managed_zone.go @@ -544,9 +544,10 @@ func flattenDNSManagedZoneLabels(v interface{}, d *schema.ResourceData) interfac } func flattenDNSManagedZoneVisibility(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "public" } + return v } diff --git a/google/resource_logging_metric.go b/google/resource_logging_metric.go index 87e6dab1f33..e69bff67fd8 100644 --- a/google/resource_logging_metric.go +++ b/google/resource_logging_metric.go @@ -586,9 +586,10 @@ func flattenLoggingMetricMetricDescriptorLabelsDescription(v interface{}, d *sch } func flattenLoggingMetricMetricDescriptorLabelsValueType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "STRING" } + return v }