mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
json img presenter needs to degrade nicely when file metadata is not present
Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
parent
feef7e28dc
commit
7544330bc2
@ -93,14 +93,18 @@ func (pres *Presenter) Present(output io.Writer) error {
|
|||||||
|
|
||||||
for idx, src := range p.Source {
|
for idx, src := range p.Source {
|
||||||
fileMetadata, err := pres.img.FileCatalog.Get(src)
|
fileMetadata, err := pres.img.FileCatalog.Get(src)
|
||||||
|
var layer int
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: test case
|
// TODO: test case
|
||||||
log.Errorf("could not get metadata from catalog (presenter=json): %+v", src)
|
log.Errorf("could not get metadata from catalog (presenter=json): %+v - error: %w", src, err)
|
||||||
|
layer = 0
|
||||||
|
} else {
|
||||||
|
layer = int(fileMetadata.Source.Metadata.Index)
|
||||||
}
|
}
|
||||||
|
|
||||||
srcObj := source{
|
srcObj := source{
|
||||||
FoundBy: p.FoundBy,
|
FoundBy: p.FoundBy,
|
||||||
Layer: int(fileMetadata.Source.Metadata.Index),
|
Layer: layer,
|
||||||
Effects: []string{}, // TODO
|
Effects: []string{}, // TODO
|
||||||
}
|
}
|
||||||
art.Sources[idx] = srcObj
|
art.Sources[idx] = srcObj
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user