mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
change dir resolver to include virtual path (#2259)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -48,7 +48,7 @@ func Test_allRegularFiles(t *testing.T) {
|
||||
return r
|
||||
},
|
||||
wantRealPaths: strset.New("file1.txt", "nested/file2.txt"),
|
||||
wantVirtualPaths: strset.New("nested/linked-file1.txt"),
|
||||
wantVirtualPaths: strset.New("file1.txt", "nested/file2.txt", "nested/linked-file1.txt"),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -68,6 +68,7 @@ func NewLocation(realPath string) Location {
|
||||
Coordinates: Coordinates{
|
||||
RealPath: realPath,
|
||||
},
|
||||
VirtualPath: realPath,
|
||||
},
|
||||
LocationMetadata: LocationMetadata{
|
||||
Annotations: map[string]string{},
|
||||
@@ -94,6 +95,7 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location {
|
||||
return Location{
|
||||
LocationData: LocationData{
|
||||
Coordinates: coordinates,
|
||||
VirtualPath: coordinates.RealPath,
|
||||
},
|
||||
LocationMetadata: LocationMetadata{
|
||||
Annotations: map[string]string{},
|
||||
@@ -137,7 +139,8 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
|
||||
Coordinates: Coordinates{
|
||||
RealPath: responsePath,
|
||||
},
|
||||
ref: ref,
|
||||
VirtualPath: responsePath,
|
||||
ref: ref,
|
||||
},
|
||||
LocationMetadata: LocationMetadata{
|
||||
Annotations: map[string]string{},
|
||||
@@ -147,9 +150,6 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
|
||||
|
||||
// NewVirtualLocationFromDirectory creates a new Location representing the given path (extracted from the Reference) relative to the given directory with a separate virtual access path.
|
||||
func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, ref file.Reference) Location {
|
||||
if responsePath == virtualResponsePath {
|
||||
return NewLocationFromDirectory(responsePath, ref)
|
||||
}
|
||||
return Location{
|
||||
LocationData: LocationData{
|
||||
Coordinates: Coordinates{
|
||||
|
||||
Reference in New Issue
Block a user