mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
structured renderer: fix closing json tags when rendering with no symbols (#32642)
This commit is contained in:
parent
7ab4e6fe2d
commit
4fa7cd0a68
@ -217,7 +217,7 @@ func (renderer primitiveRenderer) renderStringDiffAsJson(diff computed.Diff, ind
|
||||
}
|
||||
|
||||
if strings.Contains(renderedJsonDiff, "\n") {
|
||||
return fmt.Sprintf("jsonencode(%s\n%s%s%s%s\n%s)%s", whitespace, formatIndent(indent+1), writeDiffActionSymbol(action, opts), renderedJsonDiff, replace, formatIndent(indent+1), nullSuffix(diff.Action, opts))
|
||||
return fmt.Sprintf("jsonencode(%s\n%s%s%s%s\n%s%s)%s", whitespace, formatIndent(indent+1), writeDiffActionSymbol(action, opts), renderedJsonDiff, replace, formatIndent(indent), writeDiffActionSymbol(plans.NoOp, opts), nullSuffix(diff.Action, opts))
|
||||
}
|
||||
return fmt.Sprintf("jsonencode(%s)%s%s", renderedJsonDiff, whitespace, replace)
|
||||
}
|
||||
|
@ -2062,6 +2062,23 @@ jsonencode(
|
||||
+ 0,
|
||||
+ 1,
|
||||
]
|
||||
`,
|
||||
},
|
||||
"json_string_no_symbols": {
|
||||
diff: computed.Diff{
|
||||
Renderer: Primitive("{\"key\":\"value\"}", "{\"key\":\"value\"}", cty.String),
|
||||
Action: plans.NoOp,
|
||||
},
|
||||
opts: computed.RenderHumanOpts{
|
||||
HideDiffActionSymbols: true,
|
||||
ShowUnchangedChildren: true,
|
||||
},
|
||||
expected: `
|
||||
jsonencode(
|
||||
{
|
||||
key = "value"
|
||||
}
|
||||
)
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user