Skip to content

Commit

Permalink
fixed a crash (GoogleCloudPlatform#5133)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmedia authored and khajduczenia committed Oct 12, 2021
1 parent 29d6580 commit 38b60b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
If it is not provided, the provider region is used.
enable: !ruby/object:Overrides::Terraform::PropertyOverride
custom_expand: 'templates/terraform/custom_expand/bool_to_upper_string.erb'
custom_flatten: 'templates/terraform/custom_flatten/string_to_bool.erb'
custom_flatten: 'templates/terraform/custom_flatten/string_to_bool_default_true.erb'
send_empty_value: true
ipAddress: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
Expand Down
17 changes: 10 additions & 7 deletions mmv1/templates/terraform/custom_flatten/string_to_bool.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} {
b, err := strconv.ParseBool(v.(string))
if err != nil {
// If we can't convert it into a bool return value as is and let caller handle it
return v
}
return b
}
if v == nil {
return v
}
b, err := strconv.ParseBool(v.(string))
if err != nil {
// If we can't convert it into a bool return value as is and let caller handle it
return v
}
return b
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return true
}
b, err := strconv.ParseBool(v.(string))
if err != nil {
// If we can't convert it into a bool return value as is and let caller handle it
return v
}
return b
}

0 comments on commit 38b60b3

Please sign in to comment.