Skip to content

Commit

Permalink
Add default_if_empty to google_compute_router_nat defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
rileykarson authored and modular-magician committed Jan 9, 2020
1 parent 5957448 commit d6e23fe
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion google/resource_access_context_manager_access_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion google/resource_access_context_manager_service_perimeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion google/resource_compute_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
16 changes: 16 additions & 0 deletions google/resource_compute_router_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion google/resource_compute_target_https_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion google/resource_dns_managed_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion google/resource_logging_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d6e23fe

Please sign in to comment.