Repository navigation
feat(alzlibtool): indent JSON files written by generate architecture --output - #251
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #251 +/- ##
==========================================
+ Coverage 49.54% 49.59% +0.05%
==========================================
Files 54 54
Lines 4967 4968 +1
==========================================
+ Hits 2461 2464 +3
+ Misses 2210 2209 -1
+ Partials 296 295 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 of 5 tasks
Akshay Rohilla (akshayrohilla)
approved these changes
Oct 8, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 8, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
alzlibtool generate architecture --outputnow writes every per-asset JSON file indented with two spaces instead of on a single line, so the library files vendored by the ALZ Bicep accelerator can be read and reviewed.Refs Azure/Azure-Landing-Zones#4278. This PR does not close the issue by itself: the accelerator still has to regenerate its library with a release that contains this change.
No flag is added. Only whitespace changes in the exported files, and the JSON printed to stdout (without
--output) is unchanged.Problem
The library files in alz-bicep-accelerator, for example
templates/core/governance/lib/alz/landingzones/Audit-AppGW-WAF.alz_policy_assignment.json, are a single line of JSON, while the source files in Azure-Landing-Zones-Library are formatted. Users who review library updates before merging them cannot read these files without reformatting them first.The single line comes from
writeJSONFileindeployment/writer_fs.go, which encodes each asset with ajson.Encoderthat has no indentation. All four asset types (policy assignments, policy definitions, policy set definitions and role definitions) are written through it, with or without--for-alz-bicep. All 679 library files committed in alz-bicep-accelerator@bfe88af (319 undertemplates/core/governance/lib, 360 underexamples/slz/templates/core/governance/lib) are exactly what this encoder produces for their content, and no later step in the accelerator reformats them.Changes
deployment/writer_fs.gowriteJSONFile: addenc.SetIndent("", " ")deployment/writer_fs_test.goTest_writeJSONFile_indented, which asserts the exact bytes writtenTwo spaces match the source library files. HTML escaping (still disabled), key order, ARM escaping, file names and the trailing newline are unchanged.
Deployment size
The issue discussion raised the concern that formatted files could push deployments towards the 4 MB ARM template limit. The indentation does not reach the deployed template:
loadJsonContent()(319 references in the main templates, 360 in the SLZ example, noloadTextContent()). Bicep parses the JSON and re-serializes it into the compiled template.int-root, 1,600,990 bytes) does not change.loadJsonContent()per-file limit of 1,048,576 characters. The largest file,Deploy-Private-DNS-Zones.alz_policy_set_definition.json, is 97,552 bytes when indented (9.3% of the limit).Testing
Test_writeJSONFile_indentedfails onmain(the file is one line) and passes with this change. It also pins disabled HTML escaping, empty{}and[], and[[ARM escapes.deploymentwriter tests and thecmd/alzlibtool/command/generatetests pass. These run offline.alzlibtoolfrommainand from this branch and rangenerate architectureontestdata/simple, with and without--for-alz-bicep. In both modes the 8 exported files differ only in whitespace and are the canonical two-space indentation of the previous output. Stdout without--outputis byte-identical.go vet ./...,GOOS=linux GOARCH=386 go build ./...andgolangci-lintv2.11.4 with the repository configuration: no findings onmainor on this branch.Backwards compatibility
generate architecture --output(deployment.FSWriter) change, whitespace only. Anything that parses the files as JSON is unaffected. Repositories that commit the generated files get a one-time, whitespace-only diff on their next regeneration.FSWriterOptionsand all flags are unchanged.Out of scope
templates/core/governance/lib/alzandexamples/slz/templates/core/governance/lib/alzshould be regenerated with the newalzlibtoolin a format-only PR that keeps the libraryrefunchanged. The "Updating the ALZ Library Version" guide already tells users to download the latestalzlibtool, so no documentation change is needed.FSWriterOptionsfield if a consumer needs it; none does today.