From c39858dc4537d24407f86ee91d18b1e35d9c9b83 Mon Sep 17 00:00:00 2001 From: Dana Hoffman Date: Fri, 3 Jan 2020 15:01:04 -0800 Subject: [PATCH] revert bigtable change and fix flatten_object in update --- .../bigtable_app_profile_routing.erb | 2 +- templates/terraform/resource.erb | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/templates/terraform/custom_expand/bigtable_app_profile_routing.erb b/templates/terraform/custom_expand/bigtable_app_profile_routing.erb index fc139117ce32..a92df5fe824b 100644 --- a/templates/terraform/custom_expand/bigtable_app_profile_routing.erb +++ b/templates/terraform/custom_expand/bigtable_app_profile_routing.erb @@ -17,5 +17,5 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T return nil, nil } - return map[string]interface{}{}, nil + return bigtableadmin.MultiClusterRoutingUseAny{}, nil } diff --git a/templates/terraform/resource.erb b/templates/terraform/resource.erb index b74aee6f12a8..99403e234ff5 100644 --- a/templates/terraform/resource.erb +++ b/templates/terraform/resource.erb @@ -539,10 +539,12 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' || `NullFields` is a special case of `send_empty_value` where the empty value in question is go's literal nil. -%> -<% unless prop.send_empty_value -%> - } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop)) { -<% else -%> +<% if prop.send_empty_value -%> } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop) { +<% elsif prop.flatten_object -%> + } else if !isEmptyValue(reflect.ValueOf(<%= prop.api_name -%>Prop)) { +<% else -%> + } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop)) { <% end -%> obj["<%= prop.api_name -%>"] = <%= prop.api_name -%>Prop } @@ -611,10 +613,12 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' || <%= prop.api_name -%>Prop, err := expand<%= resource_name -%><%= titlelize_property(prop) -%>(<%= schemaPrefix -%>, d, config) if err != nil { return err -<% unless prop.send_empty_value -%> - } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop)) { -<% else -%> +<% if prop.send_empty_value -%> } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop) { +<% elsif prop.flatten_object -%> + } else if !isEmptyValue(reflect.ValueOf(<%= prop.api_name -%>Prop)) { +<% else -%> + } else if v, ok := d.GetOkExists("<%= prop.name.underscore -%>"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, <%= prop.api_name -%>Prop)) { <% end -%> obj["<%= prop.api_name -%>"] = <%= prop.api_name -%>Prop }