mirror of
https://github.com/anchore/syft.git
synced 2026-04-01 14:43:29 +02:00
* refactor source API and syft json source block Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update source detection and format test utils Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * generate list of all source metadata types Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * extract base and root normalization into helper functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * preserve syftjson model package name import ref Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * alias should not be a pointer Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
23 lines
464 B
Go
23 lines
464 B
Go
package spdxhelpers
|
|
|
|
import (
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func DocumentName(srcMetadata source.Description) string {
|
|
if srcMetadata.Name != "" {
|
|
return srcMetadata.Name
|
|
}
|
|
|
|
switch metadata := srcMetadata.Metadata.(type) {
|
|
case source.StereoscopeImageSourceMetadata:
|
|
return metadata.UserInput
|
|
case source.DirectorySourceMetadata:
|
|
return metadata.Path
|
|
case source.FileSourceMetadata:
|
|
return metadata.Path
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|