upjet icon indicating copy to clipboard operation
upjet copied to clipboard

add json encoded debug logging of diff detected instead of GoString to ensure readability

Open larhauga opened this issue 10 months ago • 2 comments

Description of your changes

This change will provide debug logging in json format instead of go string. This will help when debugging why changes are not affected as this may be the only way you can figure out the different quirks of the cloud provider APIs.

This will remove type information from the output logs, but it will be parsable.

Fixes #

I have:

  • [x] Read and followed Upjet's contribution process.
  • [x] Run make reviewable to ensure this PR is ready for review.
  • [ ] Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Printed out the new format during test run.

2025-02-28T17:39:20+01:00       DEBUG   provider-aws    Diff detected   
{"instanceDiff": "{\"attributes\":
{\"name\":
{\"Old\":\"example2\",
\"New\":\"example\",
\"NewComputed\":false,
\"NewRemoved\":false,
\"NewExtra\":null,
\"RequiresNew\":false,
\"Sensitive\":false,
\"Type\":0}},
\"destroy\":false,
\"destroyTainted\":false,
\"destroyDeposed\":false}"}
2025-02-28T17:40:28+01:00       DEBUG   provider-aws    Diff detected   
{"instanceDiff": "*terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{
\"name\":*terraform.ResourceAttrDiff{
Old:\"example2\", New:\"example\", 
NewComputed:false, NewRemoved:false, 
NewExtra:interface {}(nil), RequiresNew:false, 
Sensitive:false, Type:0x0}}, Destroy:false, 
DestroyDeposed:false, DestroyTainted:false, 
RawConfig:cty.NilVal, RawState:cty.NilVal, 
RawPlan:cty.NilVal, Meta:map[string]interface {}(nil)}"}

larhauga avatar Feb 28 '25 16:02 larhauga

@larhauga can you update this PR based on the feedback on needing an else clause?

stevendborrelli avatar Jun 19 '25 16:06 stevendborrelli

@larhauga can you update this PR based on the feedback on needing an else clause?

Sorry for the delay! Added the else clause now :)

larhauga avatar Jun 19 '25 16:06 larhauga