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:
Alex Goodman
2023-05-24 17:06:38 -04:00
committed by GitHub
parent 4bf17a94b9
commit 07e76907f6
313 changed files with 2316 additions and 2191 deletions
+17 -17
View File
@@ -8,14 +8,14 @@ import (
"github.com/stretchr/testify/require"
"github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/source"
"github.com/anchore/syft/syft/file"
)
func Test_Hash(t *testing.T) {
loc1 := source.NewLocation("place!")
loc1 := file.NewLocation("place!")
loc1.FileSystemID = "fs1"
loc2 := source.NewLocation("place!")
loc2 := file.NewLocation("place!")
loc2.FileSystemID = "fs2" // important! there is a different file system ID
lic1 := NewLicenseFromLocations("MIT", loc1)
@@ -47,44 +47,44 @@ func Test_Sort(t *testing.T) {
{
name: "single",
licenses: []License{
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
},
expected: []License{
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
},
},
{
name: "multiple",
licenses: []License{
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
NewLicenseFromURLs("MIT", "https://github.com/anchore/syft/blob/main/LICENSE"),
NewLicenseFromLocations("Apache", source.NewLocation("area!")),
NewLicenseFromLocations("gpl2+", source.NewLocation("area!")),
NewLicenseFromLocations("Apache", file.NewLocation("area!")),
NewLicenseFromLocations("gpl2+", file.NewLocation("area!")),
},
expected: Licenses{
NewLicenseFromLocations("Apache", source.NewLocation("area!")),
NewLicenseFromLocations("Apache", file.NewLocation("area!")),
NewLicenseFromURLs("MIT", "https://github.com/anchore/syft/blob/main/LICENSE"),
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("gpl2+", source.NewLocation("area!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
NewLicenseFromLocations("gpl2+", file.NewLocation("area!")),
},
},
{
name: "multiple with location variants",
licenses: []License{
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("MIT", source.NewLocation("park!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
NewLicenseFromLocations("MIT", file.NewLocation("park!")),
NewLicense("MIT"),
NewLicense("AAL"),
NewLicense("Adobe-2006"),
NewLicenseFromLocations("Apache", source.NewLocation("area!")),
NewLicenseFromLocations("Apache", file.NewLocation("area!")),
},
expected: Licenses{
NewLicense("AAL"),
NewLicense("Adobe-2006"),
NewLicenseFromLocations("Apache", source.NewLocation("area!")),
NewLicenseFromLocations("Apache", file.NewLocation("area!")),
NewLicense("MIT"),
NewLicenseFromLocations("MIT", source.NewLocation("park!")),
NewLicenseFromLocations("MIT", source.NewLocation("place!")),
NewLicenseFromLocations("MIT", file.NewLocation("park!")),
NewLicenseFromLocations("MIT", file.NewLocation("place!")),
},
},
}