fix: do not create SBOM for packages without SBOMable material#3540
fix: do not create SBOM for packages without SBOMable material#3540AustinAbro321 merged 7 commits intomainfrom
Conversation
✅ Deploy Preview for zarf-docs canceled.
|
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
| } | ||
| } | ||
|
|
||
| l.Info("package successfully removed", "name", pkg.Metadata.Name) |
There was a problem hiding this comment.
Adding this in here as an aside. Someone gave me feedback that zarf package remove feels strange since it doesn't give any confirmation that the remove happened successfully, I would agree
Codecov ReportAttention: Patch coverage is
|
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
mkcp
left a comment
There was a problem hiding this comment.
ErrNoSBOMAvailable has a chance to return some debugging metadata from PackageLayout.GetSBOM. Recommend declaring it as a custom error type. Everything else looks good - test case especially.
| require.NoError(t, err) | ||
| } | ||
|
|
||
| func TestGetSBOM(t *testing.T) { |
| // ErrNoSBOMAvailable is returned when a user tries to access a package SBOM, but it is not available | ||
| var ErrNoSBOMAvailable = errors.New("zarf package does not have an SBOM available") | ||
|
|
||
| // GetSBOM outputs the SBOM data from the package to the give destination path. | ||
| func (p *PackageLayout) GetSBOM(destPath string) (string, error) { | ||
| if !p.Pkg.IsSBOMAble() { | ||
| return "", ErrNoSBOMAvailable | ||
| } |
There was a problem hiding this comment.
Blocking: Let's declare ErrNoSBOMAvailable as a custom error type rather than a named error string. The message could pass back the package name or sha as metadata e.g. :
...
(e *NoSBOMAvailableError) Error() string {
return fmt.Sprintf("zarf package does not have an SBOM available, package=%s", e.package)
}
There was a problem hiding this comment.
I like this, will implement now
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
…dev#3540) Signed-off-by: Austin Abro <AustinAbro321@gmail.com> Signed-off-by: NevinAragam <nevin.aragam@gmail.com>
Description
do not create SBOM for packages without SBOMable material, looks like a bug from the create refactor
Related Issue
Fixes #3524
Checklist before merging