Skip to content

Commit

Permalink
indent JSON files generated by fetch-deps command
Browse files Browse the repository at this point in the history
within user request, we write out json files
(bom.json, .build-config.json) by `model_dump_json()`method,
but with no indentation so the output is a huge one-line file

unlike generating data in integration tests:
https://github.com/containerbuildsystem/cachi2/blob/main/tests/integration/utils.py#L228

Signed-off-by: Michal Šoltis <[email protected]>
  • Loading branch information
slimreaper35 committed Mar 22, 2024
1 parent be86e44 commit d977c79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cachi2/interface/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ def combine_option_and_json_flags(json_flags: list[Flag]) -> list[str]:

request.output_dir.path.mkdir(parents=True, exist_ok=True)
request.output_dir.join_within_root(".build-config.json").path.write_text(
request_output.build_config.model_dump_json()
request_output.build_config.model_dump_json(indent=2)
)

sbom = request_output.generate_sbom()
request.output_dir.join_within_root("bom.json").path.write_text(
# the Sbom model has camelCase aliases in some fields
sbom.model_dump_json(by_alias=True, exclude_none=True)
sbom.model_dump_json(indent=2, by_alias=True, exclude_none=True)
)

log.info(r"All dependencies fetched successfully \o/")
Expand Down

0 comments on commit d977c79

Please sign in to comment.