Skip to content

Commit

Permalink
Patch: form, flow expand interface array (#1058)
Browse files Browse the repository at this point in the history
* fix auth_form expand interface array

* fix auth_flow expand interface array
  • Loading branch information
kushalshit27 authored Oct 31, 2024
1 parent c9e8550 commit b81a13a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
24 changes: 8 additions & 16 deletions internal/auth0/flow/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,20 @@ func expandInterfaceArray(d *schema.ResourceData, key string) []interface{} {
return result
}

if oldMetadata == "" {
if newMetadataStr, ok := newMetadata.(string); ok {
var newMetadataArr []interface{}
if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil {
return nil
}
return newMetadataArr
}
return result
}

if newMetadata == "" {
return result
}

b, err := json.Marshal(newMetadata)
if err != nil {
return nil
if newMetadataStr, ok := newMetadata.(string); ok {
var newMetadataArr []interface{}
if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil {
return nil
}
return newMetadataArr
}

if err := json.Unmarshal(b, &result); err != nil {
return nil
if newMetadataArr, ok := newMetadata.([]interface{}); ok {
return newMetadataArr
}

return result
Expand Down
24 changes: 8 additions & 16 deletions internal/auth0/form/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,20 @@ func expandInterfaceArray(d *schema.ResourceData, key string) []interface{} {
return result
}

if oldMetadata == "" {
if newMetadataStr, ok := newMetadata.(string); ok {
var newMetadataArr []interface{}
if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil {
return nil
}
return newMetadataArr
}
return result
}

if newMetadata == "" {
return result
}

b, err := json.Marshal(newMetadata)
if err != nil {
return nil
if newMetadataStr, ok := newMetadata.(string); ok {
var newMetadataArr []interface{}
if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil {
return nil
}
return newMetadataArr
}

if err := json.Unmarshal(b, &result); err != nil {
return nil
if newMetadataArr, ok := newMetadata.([]interface{}); ok {
return newMetadataArr
}

return result
Expand Down

0 comments on commit b81a13a

Please sign in to comment.