-
Notifications
You must be signed in to change notification settings - Fork 587
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
Simplify the SBOM writer interface #1892
Conversation
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Benchmark Test ResultsBenchmark results from the latest changes vs base branch
|
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
type nopWriteCloser struct { | ||
io.Writer | ||
} | ||
|
||
func (n nopWriteCloser) Close() error { | ||
return nil | ||
} |
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.
nit: organization -- it would probably be good to keep all the sbomMultiWriter
stuff together
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.
yeah, this file got a little awkward, but believe it or not the #1888 PR is about to remove this (the nopWriteCloser) since it will write the the event bus. I split out this work to make the bubbletea PR smaller :)
* remove sbom.writer bytes call and consolidate helpers to options pkg Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * dont close stdout Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove close operation from multiwriter Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This PR attempts to simplify the
sbom.Writer
interface by removing required methods and consolidating helper functions for writers to thecmd/options
package.This reduces the current interface:
To this:
The primary reasons being:
Close()
isn't necessary. TheWrite()
call should implicitly close any destination.Bytes(...) []bytes ...
is ultimately a reading call, not a writing call, which is the opposite meaning of this interfaceAdditionally, many of the helpers around making writers are in the same
sbom
package, however, these helpers seem primarily targeted towards the CLI argument parsing, which should reside under thecmd
package. This is why many of the writer helpers have been moved tocmd/options
.This change cause downstream changes necessary in the
attest
command so took additional time simplifying sbom.Writer usage in that command.Partially addresses syft 1.0 work.