mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
--------- Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
25 lines
458 B
Go
25 lines
458 B
Go
package helpers
|
|
|
|
import (
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func DocumentName(src source.Description) string {
|
|
if src.Name != "" {
|
|
return src.Name
|
|
}
|
|
|
|
switch metadata := src.Metadata.(type) {
|
|
case source.ImageMetadata:
|
|
return metadata.UserInput
|
|
case source.OCIModelMetadata:
|
|
return metadata.UserInput
|
|
case source.DirectoryMetadata:
|
|
return metadata.Path
|
|
case source.FileMetadata:
|
|
return metadata.Path
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|