-
Notifications
You must be signed in to change notification settings - Fork 726
Add option to output SBOM report to a file #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Benchmark Test ResultsBenchmark results from the latest changes vs base branch |
Signed-off-by: Alex Goodman <[email protected]>
0c11369 to
a5e7281
Compare
internal/ui/select.go
Outdated
| // Select is responsible for determining the specific UI function given select user option, the current platform | ||
| // config values, and environment status (such as a TTY being present). | ||
| func Select(verbose, quiet bool) UI { | ||
| func Select(verbose, quiet bool, reportWriter io.Writer) UI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to explain the correct usage of this new parameter (even very briefly) in the function's doc comment
internal/config/application.go
Outdated
| type Application struct { | ||
| ConfigPath string `yaml:",omitempty" json:"configPath"` // the location where the application config was read from (either from -c or discovered while loading) | ||
| Output string `yaml:"output" json:"output" mapstructure:"output"` // -o, the Presenter hint string to use for report formatting | ||
| File string `yaml:"file" json:"file" mapstructure:"file"` // -f, the file to write report output to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably remove -f from this line's comment for now
cmd/root.go
Outdated
| rootCmd.PersistentFlags().CountVarP(&persistentOpts.Verbosity, "verbose", "v", "increase verbosity (-v = info, -vv = debug)") | ||
|
|
||
| rootCmd.PersistentFlags().StringP( | ||
| "file", "f", "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the "f" for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was my bad --I removed it but was restoring work from the reflog and accidentally brought it back. Removing again...
cmd/report_writer.go
Outdated
| } | ||
| return reportFile, func() error { | ||
| if !appConfig.Quiet { | ||
| _, _ = fmt.Fprintf(os.Stderr, "Report written to %q\n", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: Can we not use logging here?
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
|
Just as a note, most command line applications seem to use |
* add output to file option Signed-off-by: Alex Goodman <[email protected]> * log errors on close of the report destination Signed-off-by: Alex Goodman <[email protected]> * remove file option from persistent args Signed-off-by: Alex Goodman <[email protected]> * update file option comments and logging Signed-off-by: Alex Goodman <[email protected]> * allow for multiple UI fallback options Signed-off-by: Alex Goodman <[email protected]> * update UI select signatures + tests Signed-off-by: Alex Goodman <[email protected]>
This PR adds a new
--fileoption that writes the report bytes out to the given file path. Note: since the same functionality will be ported to grype it was decided that-fwill not be used since that option is already taken in grype.