[K9VULN-9309] Add --pretty option support#77
Conversation
| --- | ||
|
|
||
| [TestRun/not_lockfile_and_not_formatter - 1] | ||
| {"$schema":"http://cyclonedx.org/schema/bom-1.5.schema.json","bomFormat":"CycloneDX","specVersion":"1.5","version":1,"metadata":{"tools":{"components":[{"type":"application","group":"datadog","name":"datadog-sbom-generator","version":"set at build time, see .goreleaser.yml ldflags section"}]}}} |
There was a problem hiding this comment.
we make sure we are still able to output minified sbom by default
| }, | ||
| { | ||
| name: "not lockfile", | ||
| args: []string{"", "--pretty", "./fixtures/no-lockfile.txt"}, |
There was a problem hiding this comment.
before we were assuming that: if you are in a Test -> always prettify, but this means we cannot test that we are able to minifiy.. so had to add --pretty everywhere we expected it
Go test coverage reportTotal test coverage: 90.9% (3932/4325) No coverage changes in any files compared to the base. |
| encoder := json.NewEncoder(outputWriter) | ||
| encoder.SetIndent("", " ") | ||
| if pretty { | ||
| encoder.SetIndent("", " ") |
There was a problem hiding this comment.
we are somewhere screwed here. Because:
- default behavior of JSON formatter was pretty = true
- default behavior of cycloneDX formatter was pretty = false
Because of it, we cannot have a flag --pretty as an input which would rule both without causing change to existing default behavior. Because the format: cycloneDX is the default behavior, I've decided to make its behavior be the one which doesn't change (default pretty = false).
What problem are you trying to solve?
What is your solution?
Added a
--prettyflag to the SBOM generator that enables pretty-printing of JSON output. The implementation:--prettyflag to the CLI interfaceAlternatives considered
--prettyflag is simpler and more intuitiveWhat the reviewer should know
--prettyis enabled