Skip to content

Commit

Permalink
fix: check if the list or map is empty, and use Emptylist and emptyOb…
Browse files Browse the repository at this point in the history
…jects instead
  • Loading branch information
srevinsaju committed Dec 6, 2023
1 parent 97cc502 commit c044992
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/blocks/data/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,16 @@ func getObjectType(m map[string]interface{}) map[string]cty.Value {
}
typeOf := typeRaw.Kind()
if typeOf == reflect.Map {
if len(v.(map[string]interface{})) == 0 {
s[k] = cty.ObjectVal(map[string]cty.Value{})
continue
}
s[k] = cty.ObjectVal(getObjectType(v.(map[string]interface{})))
} else if typeOf == reflect.Slice {
if len(v.([]interface{})) == 0 {
s[k] = cty.ListValEmpty(cty.String)
continue
}
s[k] = cty.ListVal(getListType(v.([]interface{})))
} else {
impliedType, err := gocty.ImpliedType(v)
Expand Down

0 comments on commit c044992

Please sign in to comment.