mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
Migrate location-related structs to the file package (#1751)
* migrate location structs to file package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * replace source.Location refs with file package call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for file based catalogers Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove hardlink test for all-regular-files testing Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate file resolver implementations to separate package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * [wip] migrate resolvers to internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate resolvers to syft/internal Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: <>
This commit is contained in:
+12
-12
@@ -21,11 +21,11 @@ type SBOM struct {
|
||||
|
||||
type Artifacts struct {
|
||||
Packages *pkg.Collection
|
||||
FileMetadata map[source.Coordinates]source.FileMetadata
|
||||
FileDigests map[source.Coordinates][]file.Digest
|
||||
FileContents map[source.Coordinates]string
|
||||
FileLicenses map[source.Coordinates][]file.License
|
||||
Secrets map[source.Coordinates][]file.SearchResult
|
||||
FileMetadata map[file.Coordinates]file.Metadata
|
||||
FileDigests map[file.Coordinates][]file.Digest
|
||||
FileContents map[file.Coordinates]string
|
||||
FileLicenses map[file.Coordinates][]file.License
|
||||
Secrets map[file.Coordinates][]file.SearchResult
|
||||
LinuxDistribution *linux.Release
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ func (s SBOM) RelationshipsSorted() []artifact.Relationship {
|
||||
return relationships
|
||||
}
|
||||
|
||||
func (s SBOM) AllCoordinates() []source.Coordinates {
|
||||
set := source.NewCoordinateSet()
|
||||
func (s SBOM) AllCoordinates() []file.Coordinates {
|
||||
set := file.NewCoordinateSet()
|
||||
for coordinates := range s.Artifacts.FileMetadata {
|
||||
set.Add(coordinates)
|
||||
}
|
||||
@@ -89,8 +89,8 @@ func (s SBOM) RelationshipsForPackage(p pkg.Package, rt ...artifact.Relationship
|
||||
|
||||
// CoordinatesForPackage returns all coordinates for the provided package for provided relationship types
|
||||
// If no types are provided, all relationship types are considered.
|
||||
func (s SBOM) CoordinatesForPackage(p pkg.Package, rt ...artifact.RelationshipType) []source.Coordinates {
|
||||
var coordinates []source.Coordinates
|
||||
func (s SBOM) CoordinatesForPackage(p pkg.Package, rt ...artifact.RelationshipType) []file.Coordinates {
|
||||
var coordinates []file.Coordinates
|
||||
for _, relationship := range s.RelationshipsForPackage(p, rt...) {
|
||||
cords := extractCoordinates(relationship)
|
||||
coordinates = append(coordinates, cords...)
|
||||
@@ -98,12 +98,12 @@ func (s SBOM) CoordinatesForPackage(p pkg.Package, rt ...artifact.RelationshipTy
|
||||
return coordinates
|
||||
}
|
||||
|
||||
func extractCoordinates(relationship artifact.Relationship) (results []source.Coordinates) {
|
||||
if coordinates, exists := relationship.From.(source.Coordinates); exists {
|
||||
func extractCoordinates(relationship artifact.Relationship) (results []file.Coordinates) {
|
||||
if coordinates, exists := relationship.From.(file.Coordinates); exists {
|
||||
results = append(results, coordinates)
|
||||
}
|
||||
|
||||
if coordinates, exists := relationship.To.(source.Coordinates); exists {
|
||||
if coordinates, exists := relationship.To.(file.Coordinates); exists {
|
||||
results = append(results, coordinates)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user