HclUtility
Index
Constructors
Methods
Constructors
constructor
Returns HclUtility
Methods
staticdiffBlocks
Diffs two serialize renders at the block level. A block is identified by its header line, and blocks sharing a header (one
provider "aws"per alias) by their first body line too, so a body change reads as~(a line-level unifiedDiff of what changed inside the block), not as an unrelated add + remove. An added block shows its full new body, a removed block its full old body — symmetric, with nothing trimmed away. The+/-/~vocabulary mirrors thedigestDiffsdigest, tagged withmoduleId/file. Returns'<no changes>'when nothing moved.Parameters
previous: string
current: string
Returns string
staticparse
Reads the
resourceanddatablocks of rendered terraform, keyed by their terraform address:<type>.<name>for a resource,data.<type>.<name>for a data source. It takes one file's text or a whole serialize render, such as thehclRendera module test gets back, since resource and data addresses are unique across an app.It reads octo's own render format, not arbitrary HCL: one attribute or block per line, and a value spanning lines only inside brackets.
Parameters
hcl: string
Returns { data: Record<string, HclBlock>; resource: Record<string, HclBlock> }
staticserialize
Flattens the rendered terragrunt folders into one snapshot-friendly string: folders sorted by module id, files in a stable order, each prefixed with a
# <moduleId>/<file>header. An empty file shows a<empty>body, so the file is still visible in the snapshot rather than omitted.Parameters
moduleFiles: Map<string>
Returns string
staticunifiedDiff
Produces a git-style unified line diff of two multi-line strings, collapsing unchanged regions to at most
contextLinesof surrounding context per change and emitting@@ -a,c +b,c @@hunk headers. Changed lines are tagged-(only inbefore) and+(only inafter); context lines are tagged with two spaces, so the markers line up. Pure plain text, no ANSI color, so it is safe to embed in a snapshot.Returns an empty string when the two inputs are identical.
Parameters
before: string
after: string
__namedParameters: { contextLines?: number } = {}
optionalcontextLines: number = 3
Returns string
Reads, serializes and diffs the terraform octo renders.
The render format is octo-owned and regular:
# <moduleId>/<file>section headers, and top-level blocks that start on a line with no indent. So everything here is plain string work, needing no external HCL parser or diff library. parse reads the blocks a module test asserts on, serialize flattens a render into one string, unifiedDiff is the generic line-diff engine, and diffBlocks layers octo's block structure on top of it.Utilities/Hcl