@@ -24,7 +24,6 @@ import (
2424 pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
2525
2626 shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
27- shimutil "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/util"
2827)
2928
3029// containsComputedValues returns true if the given property value is or contains a computed value.
@@ -70,7 +69,7 @@ type propertyVisitor func(attributeKey, propertyPath string, value resource.Prop
7069// check to see if the InstanceDiff has an entry for that path.
7170func visitPropertyValue (
7271 ctx context.Context , name , path string , v resource.PropertyValue , tfs shim.Schema ,
73- ps * SchemaInfo , rawNames bool , visitor propertyVisitor ) {
72+ ps * SchemaInfo , visitor propertyVisitor ) {
7473
7574 if IsMaxItemsOne (tfs , ps ) {
7675 if v .IsNull () {
@@ -127,21 +126,33 @@ func visitPropertyValue(
127126 }
128127
129128 en := name + "." + ti
130- visitPropertyValue (ctx , en , ep , e , etfs , eps , rawNames , visitor )
129+ visitPropertyValue (ctx , en , ep , e , etfs , eps , visitor )
131130 }
132131 case v .IsObject ():
133- var tfflds shim.SchemaMap
134132 if tfs != nil {
135- if res , isres := tfs .Elem ().(shim.Resource ); isres {
136- tfflds = res .Schema ()
133+ if res , ok := tfs .Elem ().(shim.Resource ); ok {
134+ tfflds := res .Schema ()
135+ var psflds map [string ]* SchemaInfo
136+ if ps != nil {
137+ psflds = ps .Fields
138+ }
139+
140+ for k , e := range v .ObjectValue () {
141+ var elementPath string
142+ if strings .ContainsAny (string (k ), `."[]` ) {
143+ elementPath = fmt .Sprintf (`%s.["%s"]` , path , strings .ReplaceAll (string (k ), `"` , `\"` ))
144+ } else {
145+ elementPath = fmt .Sprintf ("%s.%s" , path , k )
146+ }
147+
148+ en , etf , eps := getInfoFromPulumiName (k , tfflds , psflds , false )
149+ visitPropertyValue (ctx , name + "." + en , elementPath , e , etf , eps , visitor )
150+ }
151+ return
137152 }
138153 }
139- var psflds map [string ]* SchemaInfo
140- if ps != nil {
141- psflds = ps .Fields
142- }
143154
144- rawElementNames := rawNames || shimutil . IsOfTypeMap (tfs )
155+ etfs , eps := elemSchemas (tfs , ps )
145156 for k , e := range v .ObjectValue () {
146157 var elementPath string
147158 if strings .ContainsAny (string (k ), `."[]` ) {
@@ -150,8 +161,7 @@ func visitPropertyValue(
150161 elementPath = fmt .Sprintf ("%s.%s" , path , k )
151162 }
152163
153- en , etf , eps := getInfoFromPulumiName (k , tfflds , psflds , rawElementNames )
154- visitPropertyValue (ctx , name + "." + en , elementPath , e , etf , eps , rawElementNames , visitor )
164+ visitPropertyValue (ctx , name + "." + string (k ), elementPath , e , etfs , eps , visitor )
155165 }
156166 }
157167}
@@ -166,7 +176,7 @@ func makePropertyDiff(
166176 forceDiff * bool ,
167177 tfs shim.Schema ,
168178 ps * SchemaInfo ,
169- finalize , rawNames bool ,
179+ finalize bool ,
170180) {
171181
172182 visitor := func (name , path string , v resource.PropertyValue ) bool {
@@ -257,7 +267,7 @@ func makePropertyDiff(
257267 return false
258268 }
259269
260- visitPropertyValue (ctx , name , path , v , tfs , ps , rawNames , visitor )
270+ visitPropertyValue (ctx , name , path , v , tfs , ps , visitor )
261271}
262272
263273func newIgnoreChanges (
@@ -296,11 +306,11 @@ func computeIgnoreChanges(
296306 }
297307 for k , v := range olds {
298308 en , etf , eps := getInfoFromPulumiName (k , tfs , ps , false )
299- visitPropertyValue (ctx , en , string (k ), v , etf , eps , shimutil . IsOfTypeMap ( etf ), visitor )
309+ visitPropertyValue (ctx , en , string (k ), v , etf , eps , visitor )
300310 }
301311 for k , v := range news {
302312 en , etf , eps := getInfoFromPulumiName (k , tfs , ps , false )
303- visitPropertyValue (ctx , en , string (k ), v , etf , eps , shimutil . IsOfTypeMap ( etf ), visitor )
313+ visitPropertyValue (ctx , en , string (k ), v , etf , eps , visitor )
304314 }
305315 return ignoredKeySet
306316}
@@ -353,17 +363,17 @@ func makeDetailedDiffExtra(
353363 for k , v := range olds {
354364 en , etf , eps := getInfoFromPulumiName (k , tfs , ps , false )
355365 makePropertyDiff (ctx , en , string (k ), v , tfDiff , diff , collectionDiffs , forceDiff ,
356- etf , eps , false , shimutil . IsOfTypeMap ( etf ) )
366+ etf , eps , false )
357367 }
358368 for k , v := range news {
359369 en , etf , eps := getInfoFromPulumiName (k , tfs , ps , false )
360370 makePropertyDiff (ctx , en , string (k ), v , tfDiff , diff , collectionDiffs , forceDiff ,
361- etf , eps , false , shimutil . IsOfTypeMap ( etf ) )
371+ etf , eps , false )
362372 }
363373 for k , v := range olds {
364374 en , etf , eps := getInfoFromPulumiName (k , tfs , ps , false )
365375 makePropertyDiff (ctx , en , string (k ), v , tfDiff , diff , collectionDiffs , forceDiff ,
366- etf , eps , true , shimutil . IsOfTypeMap ( etf ) )
376+ etf , eps , true )
367377 }
368378
369379 changes := pulumirpc .DiffResponse_DIFF_NONE
0 commit comments