@@ -258,20 +258,21 @@ func (m *preserveAMD64ArchsModifier) PlanModifySet(ctx context.Context, req plan
258
258
return
259
259
}
260
260
261
- var configURL , planURL , configSHA , planSHA types.String
261
+ var configURL , stateURL , configSHA , stateSHA types.String
262
262
263
263
// Get values from state and plan
264
264
req .Config .GetAttribute (ctx , path .Root ("url" ), & configURL )
265
- req .Plan .GetAttribute (ctx , path .Root ("url" ), & planURL )
266
- req .State .GetAttribute (ctx , path .Root ("sha" ), & configSHA )
267
- req .Plan .GetAttribute (ctx , path .Root ("sha" ), & planSHA )
265
+ req .State .GetAttribute (ctx , path .Root ("url" ), & stateURL )
266
+ req .Config .GetAttribute (ctx , path .Root ("sha" ), & configSHA )
267
+ req .State .GetAttribute (ctx , path .Root ("sha" ), & stateSHA )
268
268
269
269
// Check if values are changing
270
- urlChanged := ! configURL .Equal (planURL )
271
- shaChanged := ! configSHA .Equal (planSHA )
270
+ urlChanged := ! configURL .Equal (stateURL )
271
+ shaChanged := ! configSHA .Equal (stateSHA )
272
272
273
273
// If neither URL nor SHA is changing, do nothing
274
274
if ! urlChanged && ! shaChanged {
275
+ tflog .Debug (ctx , "No changes to URL or SHA, skipping AMD64 architecture preservation" )
275
276
return
276
277
}
277
278
@@ -302,9 +303,9 @@ func (m *preserveAMD64ArchsModifier) PlanModifySet(ctx context.Context, req plan
302
303
"urlChanged" : urlChanged ,
303
304
"shaChanged" : shaChanged ,
304
305
"stateURL" : configURL ,
305
- "planURL" : planURL ,
306
+ "planURL" : stateURL ,
306
307
"stateSHA" : configSHA ,
307
- "planSHA" : planSHA ,
308
+ "planSHA" : stateSHA ,
308
309
})
309
310
// Check if AMD64 is already in the plan
310
311
for _ , arch := range planArchsList {
@@ -321,7 +322,7 @@ func (m *preserveAMD64ArchsModifier) PlanModifySet(ctx context.Context, req plan
321
322
arch .URL = configURL
322
323
}
323
324
if shaChanged {
324
- arch .Sha = configURL
325
+ arch .Sha = configSHA
325
326
}
326
327
327
328
// Update the plan with the modified AMD64 arch
@@ -335,6 +336,12 @@ func (m *preserveAMD64ArchsModifier) PlanModifySet(ctx context.Context, req plan
335
336
"arch" : arch .Arch ,
336
337
},
337
338
)
339
+ tflog .Debug (ctx , "Updating AMD64 architecture in plan" , map [string ]interface {}{
340
+ "url" : arch .URL .ValueString (),
341
+ "sha" : arch .Sha .ValueString (),
342
+ "os" : arch .OS .ValueString (),
343
+ "arch" : arch .Arch .ValueString (),
344
+ })
338
345
339
346
resp .PlanValue = types .SetValueMust (archObjectType , []attr.Value {attrValue })
340
347
return
@@ -415,7 +422,8 @@ func (m *SyncTopLevelURLSHAWithAMD64Modifier) PlanModifyString(ctx context.Conte
415
422
}
416
423
417
424
if amd64Arch .Arch .IsNull () || amd64Arch .Arch .IsUnknown () {
418
- tflog .Debug (ctx , "No AMD64 architecture found in config archs, skipping modification" )
425
+ // set the plan's top level URL/SHA to null
426
+ resp .PlanValue = types .StringNull ()
419
427
return
420
428
}
421
429
@@ -435,70 +443,3 @@ func (m *SyncTopLevelURLSHAWithAMD64Modifier) PlanModifyString(ctx context.Conte
435
443
}
436
444
437
445
}
438
-
439
- //
440
- // // ValidateToolVersion provides common validation for tool version resources
441
- // func ValidateToolVersion(ctx context.Context, url, sha types.String, archs types.Set, resourceType string) diag.Diagnostics {
442
- // var diags diag.Diagnostics
443
-
444
- // urlPresent := !url.IsNull() && !url.IsUnknown()
445
- // shaPresent := !sha.IsNull() && !sha.IsUnknown()
446
-
447
- // // If URL or SHA is not set, we will rely on the archs attribute
448
- // if !urlPresent || !shaPresent {
449
- // return diags
450
- // }
451
-
452
- // // If archs aren't present, we can't validate against them
453
- // if archs.IsNull() || archs.IsUnknown() {
454
- // return diags
455
- // }
456
-
457
- // // Extract archs
458
- // var archsList []ToolArchitecture
459
- // archDiags := archs.ElementsAs(ctx, &archsList, false)
460
- // if archDiags.HasError() {
461
- // diags.Append(archDiags...)
462
- // return diags
463
- // }
464
-
465
- // // Check for AMD64 architecture
466
- // hasAMD64 := false
467
- // var amd64Arch ToolArchitecture
468
- // for _, arch := range archsList {
469
- // if arch.Arch.ValueString() == "amd64" {
470
- // hasAMD64 = true
471
- // amd64Arch = arch
472
- // break
473
- // }
474
- // }
475
-
476
- // // If top-level URL/SHA are set and no AMD64 arch found, add error
477
- // if !hasAMD64 {
478
- // diags.AddError(
479
- // fmt.Sprintf("Missing AMD64 architecture in %s", resourceType),
480
- // "When specifying both top-level URL/SHA and archs, an AMD64 architecture entry must be included",
481
- // )
482
- // return diags
483
- // }
484
-
485
- // // If URL and SHA are set at top level, check they match AMD64 arch
486
- // if url.ValueString() != amd64Arch.URL.ValueString() {
487
- // diags.AddError(
488
- // fmt.Sprintf("Inconsistent %s URL values", resourceType),
489
- // fmt.Sprintf("Top-level URL (%s) doesn't match AMD64 architecture URL (%s)",
490
- // url.ValueString(), amd64Arch.URL.ValueString()),
491
- // )
492
- // }
493
-
494
- // // Check SHA matches
495
- // if sha.ValueString() != amd64Arch.Sha.ValueString() {
496
- // diags.AddError(
497
- // fmt.Sprintf("Inconsistent %s SHA values", resourceType),
498
- // fmt.Sprintf("Top-level SHA (%s) doesn't match AMD64 architecture SHA (%s)",
499
- // sha.ValueString(), amd64Arch.Sha.ValueString()),
500
- // )
501
- // }
502
-
503
- // return diags
504
- // }
0 commit comments