refactor(sbom): add sbom prefix + filepaths for decode log messages (#7074)

This commit is contained in:
DmitriyLewen
2024-07-03 10:24:33 +06:00
committed by GitHub
parent 1f5f348958
commit 266d9b1f4b
7 changed files with 33 additions and 25 deletions

View File

@@ -37,7 +37,7 @@ func NewArtifact(filePath string, c cache.ArtifactCache, opt artifact.Option) (a
}, nil
}
func (a Artifact) Inspect(_ context.Context) (artifact.Reference, error) {
func (a Artifact) Inspect(ctx context.Context) (artifact.Reference, error) {
f, err := os.Open(a.filePath)
if err != nil {
return artifact.Reference{}, xerrors.Errorf("failed to open sbom file error: %w", err)
@@ -51,7 +51,8 @@ func (a Artifact) Inspect(_ context.Context) (artifact.Reference, error) {
}
log.Info("Detected SBOM format", log.String("format", string(format)))
bom, err := sbom.Decode(f, format)
ctx = log.WithContextAttrs(ctx, log.FilePath(a.filePath))
bom, err := sbom.Decode(ctx, f, format)
if err != nil {
return artifact.Reference{}, xerrors.Errorf("SBOM decode error: %w", err)
}