Skip to content

Commit

Permalink
Merge pull request #23564 from wuxu92/fix/removedInNextMajorVersion
Browse files Browse the repository at this point in the history
"TypedSDK": Fix the issue with the `removedInNextMajorVersion` tag causing data loss in `Decode`
  • Loading branch information
tombuildsstuff authored Oct 16, 2023
2 parents 5c16b05 + e493c38 commit 36c64da
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/sdk/resource_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package sdk
import (
"fmt"
"reflect"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -57,6 +58,7 @@ func decodeReflectedType(input interface{}, stateRetriever stateRetriever, debug
debugLogger.Infof("Field", field)

if val, exists := field.Tag.Lookup("tfschema"); exists {
val = strings.TrimSuffix(val, ",removedInNextMajorVersion")
tfschemaValue, valExists := stateRetriever.GetOkExists(val)
if !valExists {
continue
Expand Down Expand Up @@ -192,6 +194,7 @@ func setListValue(input interface{}, index int, fieldName string, v []interface{
debugLogger.Infof("nestedField ", nestedField)

if val, exists := nestedField.Tag.Lookup("tfschema"); exists {
val = strings.TrimSuffix(val, ",removedInNextMajorVersion")
nestedTFSchemaValue := test[val]
if err := setValue(elem.Interface(), nestedTFSchemaValue, j, fieldName, debugLogger); err != nil {
return err
Expand Down

0 comments on commit 36c64da

Please sign in to comment.