@@ -224,28 +224,14 @@ func filterDefaultSourceIPs(apiSourceIPs []*string) []string {
224224func addSourceIPsIfOverridden (ctx context.Context , regionDbConfig map [string ]interface {}, d * schema.ResourceData , regionDb * databases.CrdbDatabase , region string ) {
225225 sourceIPs := filterDefaultSourceIPs (regionDb .Security .SourceIPs )
226226
227- tflog .Debug (ctx , "Read: addSourceIPsIfOverridden" , map [string ]interface {}{
228- "region" : region ,
229- "apiSourceIPsCount" : len (regionDb .Security .SourceIPs ),
230- "filteredIPsCount" : len (sourceIPs ),
231- "filteredIPs" : sourceIPs ,
232- })
233-
234227 if len (sourceIPs ) == 0 {
235- tflog .Debug (ctx , "Read: Skipping source IPs (filtered to empty)" , map [string ]interface {}{"region" : region })
236228 return
237229 }
238230
239231 globalSourceIPsPtrs := utils .SetToStringSlice (d .Get ("global_source_ips" ).(* schema.Set ))
240232 globalSourceIPs := redis .StringSliceValue (globalSourceIPsPtrs ... )
241233
242234 shouldAdd := ! stringSlicesEqual (sourceIPs , globalSourceIPs )
243- tflog .Debug (ctx , "Read: Source IPs comparison" , map [string ]interface {}{
244- "region" : region ,
245- "regionIPs" : sourceIPs ,
246- "globalIPs" : globalSourceIPs ,
247- "shouldAdd" : shouldAdd ,
248- })
249235
250236 if shouldAdd {
251237 regionDbConfig ["override_global_source_ips" ] = sourceIPs
@@ -263,24 +249,10 @@ func addDataPersistenceIfOverridden(
263249 if regionDb .DataPersistence != nil && db .GlobalDataPersistence != nil {
264250 regionValue := redis .StringValue (regionDb .DataPersistence )
265251 globalValue := redis .StringValue (db .GlobalDataPersistence )
266- shouldAdd := regionValue != globalValue
267252
268- tflog .Debug (ctx , "Read: Data persistence comparison" , map [string ]interface {}{
269- "region" : region ,
270- "regionValue" : regionValue ,
271- "globalValue" : globalValue ,
272- "shouldAdd" : shouldAdd ,
273- })
274-
275- if shouldAdd {
253+ if regionValue != globalValue {
276254 regionDbConfig ["override_global_data_persistence" ] = regionDb .DataPersistence
277255 }
278- } else {
279- tflog .Debug (ctx , "Read: Skipping data persistence (nil values)" , map [string ]interface {}{
280- "region" : region ,
281- "regionIsNil" : regionDb .DataPersistence == nil ,
282- "globalIsNil" : db .GlobalDataPersistence == nil ,
283- })
284256 }
285257}
286258
@@ -295,25 +267,10 @@ func addPasswordIfOverridden(
295267 if regionDb .Security .Password != nil && db .GlobalPassword != nil {
296268 regionValue := * regionDb .Security .Password
297269 globalValue := redis .StringValue (db .GlobalPassword )
298- shouldAdd := regionValue != globalValue
299270
300- tflog .Debug (ctx , "Read: Password comparison" , map [string ]interface {}{
301- "region" : region ,
302- "regionValue" : "[REDACTED]" ,
303- "globalValue" : "[REDACTED]" ,
304- "valuesDiffer" : shouldAdd ,
305- "shouldAdd" : shouldAdd ,
306- })
307-
308- if shouldAdd {
271+ if regionValue != globalValue {
309272 regionDbConfig ["override_global_password" ] = regionValue
310273 }
311- } else {
312- tflog .Debug (ctx , "Read: Skipping password (nil values)" , map [string ]interface {}{
313- "region" : region ,
314- "regionIsNil" : regionDb .Security .Password == nil ,
315- "globalIsNil" : db .GlobalPassword == nil ,
316- })
317274 }
318275}
319276
@@ -424,31 +381,18 @@ func addRemoteBackupIfConfigured(
424381 stateOverrideRegion map [string ]interface {},
425382 region string ,
426383) {
427- tflog .Debug (ctx , "Read: Checking remote backup" , map [string ]interface {}{
428- "region" : region ,
429- "apiHasBackup" : regionDb .Backup != nil ,
430- })
431-
432384 if regionDb .Backup == nil {
433- tflog .Debug (ctx , "Read: Skipping remote backup (nil in API)" , map [string ]interface {}{"region" : region })
434385 return
435386 }
436387
437388 stateRemoteBackup := stateOverrideRegion ["remote_backup" ]
438389 if stateRemoteBackup == nil {
439- tflog .Debug (ctx , "Read: Skipping remote backup (nil in state)" , map [string ]interface {}{"region" : region })
440390 return
441391 }
442392
443393 stateRemoteBackupList := stateRemoteBackup .([]interface {})
444- tflog .Debug (ctx , "Read: Remote backup state list" , map [string ]interface {}{
445- "region" : region ,
446- "listCount" : len (stateRemoteBackupList ),
447- })
448-
449394 if len (stateRemoteBackupList ) > 0 {
450395 regionDbConfig ["remote_backup" ] = pro .FlattenBackupPlan (regionDb .Backup , stateRemoteBackupList , "" )
451- tflog .Debug (ctx , "Read: Added remote_backup to region config" , map [string ]interface {}{"region" : region })
452396 }
453397}
454398
@@ -484,27 +428,9 @@ func addEnableDefaultUserIfNeeded(
484428 })
485429}
486430
487- // logRegionConfigBuilt logs the final region config for debugging.
488- func logRegionConfigBuilt (ctx context.Context , region string , regionDbConfig map [string ]interface {}) {
489- tflog .Debug (ctx , "Read: Completed region config" , map [string ]interface {}{
490- "region" : region ,
491- "hasEnableDefaultUser" : regionDbConfig ["enable_default_user" ] != nil ,
492- "enableDefaultUserValue" : regionDbConfig ["enable_default_user" ],
493- "hasOverrideGlobalSourceIps" : regionDbConfig ["override_global_source_ips" ] != nil ,
494- "hasOverrideGlobalDataPersistence" : regionDbConfig ["override_global_data_persistence" ] != nil ,
495- "hasOverrideGlobalPassword" : regionDbConfig ["override_global_password" ] != nil ,
496- "hasOverrideGlobalAlert" : regionDbConfig ["override_global_alert" ] != nil ,
497- "hasRemoteBackup" : regionDbConfig ["remote_backup" ] != nil ,
498- })
499- }
500-
501431// buildRegionConfigFromAPIAndState orchestrates building region config from API and state.
502432// Each override field is handled by a dedicated helper function for clarity and maintainability.
503433func buildRegionConfigFromAPIAndState (ctx context.Context , d * schema.ResourceData , db * databases.ActiveActiveDatabase , region string , regionDb * databases.CrdbDatabase , stateOverrideRegion map [string ]interface {}) map [string ]interface {} {
504- tflog .Debug (ctx , "Read: Starting buildRegionConfigFromAPIAndState" , map [string ]interface {}{
505- "region" : region ,
506- })
507-
508434 regionDbConfig := map [string ]interface {}{
509435 "name" : region ,
510436 }
@@ -517,8 +443,6 @@ func buildRegionConfigFromAPIAndState(ctx context.Context, d *schema.ResourceDat
517443 addRemoteBackupIfConfigured (ctx , regionDbConfig , regionDb , stateOverrideRegion , region )
518444 addEnableDefaultUserIfNeeded (ctx , regionDbConfig , d , db , region , regionDb )
519445
520- logRegionConfigBuilt (ctx , region , regionDbConfig )
521-
522446 return regionDbConfig
523447}
524448
0 commit comments