rename file.Location.VirtualPath to AccessPath (#2288)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-11-09 11:30:08 -06:00
committed by GitHub
parent baa3dc74d3
commit 3f13d209a5
37 changed files with 320 additions and 320 deletions
+23 -23
View File
@@ -10,7 +10,7 @@ import (
)
// Location represents a path relative to a particular filesystem resolved to a specific file.Reference. This struct is used as a key
// in content fetching to uniquely identify a file relative to a request (the VirtualPath).
// in content fetching to uniquely identify a file relative to a request (the AccessPath).
type Location struct {
LocationData `cyclonedx:""`
LocationMetadata `cyclonedx:""`
@@ -20,8 +20,8 @@ type LocationData struct {
Coordinates `cyclonedx:""` // Empty string here means there is no intermediate property name, e.g. syft:locations:0:path without "coordinates"
// note: it is IMPORTANT to ignore anything but the coordinates for a Location when considering the ID (hash value)
// since the coordinates are the minimally correct ID for a location (symlinks should not come into play)
VirtualPath string `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks
ref file.Reference `hash:"ignore"` // The file reference relative to the stereoscope.FileCatalog that has more information about this location.
AccessPath string `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks
ref file.Reference `hash:"ignore"` // The file reference relative to the stereoscope.FileCatalog that has more information about this location.
}
func (l LocationData) Reference() file.Reference {
@@ -68,7 +68,7 @@ func NewLocation(realPath string) Location {
Coordinates: Coordinates{
RealPath: realPath,
},
VirtualPath: realPath,
AccessPath: realPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -77,13 +77,13 @@ func NewLocation(realPath string) Location {
}
// NewVirtualLocation creates a new location for a path accessed by a virtual path (a path with a symlink or hardlink somewhere in the path)
func NewVirtualLocation(realPath, virtualPath string) Location {
func NewVirtualLocation(realPath, accessPath string) Location {
return Location{
LocationData: LocationData{
Coordinates: Coordinates{
RealPath: realPath,
},
VirtualPath: virtualPath,
AccessPath: accessPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -95,7 +95,7 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location {
return Location{
LocationData: LocationData{
Coordinates: coordinates,
VirtualPath: coordinates.RealPath,
AccessPath: coordinates.RealPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -103,11 +103,11 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location {
}
// NewVirtualLocationFromCoordinates creates a new location for the given Coordinates via a virtual path.
func NewVirtualLocationFromCoordinates(coordinates Coordinates, virtualPath string) Location {
func NewVirtualLocationFromCoordinates(coordinates Coordinates, accessPath string) Location {
return Location{
LocationData: LocationData{
Coordinates: coordinates,
VirtualPath: virtualPath,
AccessPath: accessPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -115,7 +115,7 @@ func NewVirtualLocationFromCoordinates(coordinates Coordinates, virtualPath stri
}
// NewLocationFromImage creates a new Location representing the given path (extracted from the Reference) relative to the given image.
func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Image) Location {
func NewLocationFromImage(accessPath string, ref file.Reference, img *image.Image) Location {
layer := img.FileCatalog.Layer(ref)
return Location{
LocationData: LocationData{
@@ -123,8 +123,8 @@ func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Ima
RealPath: string(ref.RealPath),
FileSystemID: layer.Metadata.Digest,
},
VirtualPath: virtualPath,
ref: ref,
AccessPath: accessPath,
ref: ref,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -139,8 +139,8 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
Coordinates: Coordinates{
RealPath: responsePath,
},
VirtualPath: responsePath,
ref: ref,
AccessPath: responsePath,
ref: ref,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -149,14 +149,14 @@ 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 {
func NewVirtualLocationFromDirectory(responsePath, responseAccessPath string, ref file.Reference) Location {
return Location{
LocationData: LocationData{
Coordinates: Coordinates{
RealPath: responsePath,
},
VirtualPath: virtualResponsePath,
ref: ref,
AccessPath: responseAccessPath,
ref: ref,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -164,9 +164,9 @@ func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, r
}
}
func (l Location) AccessPath() string {
if l.VirtualPath != "" {
return l.VirtualPath
func (l Location) Path() string {
if l.AccessPath != "" {
return l.AccessPath
}
return l.RealPath
}
@@ -179,8 +179,8 @@ func (l Location) String() string {
str += fmt.Sprintf("RealPath=%q", l.RealPath)
if l.VirtualPath != "" && l.VirtualPath != l.RealPath {
str += fmt.Sprintf(" VirtualPath=%q", l.VirtualPath)
if l.AccessPath != "" && l.AccessPath != l.RealPath {
str += fmt.Sprintf(" AccessPath=%q", l.AccessPath)
}
if l.FileSystemID != "" {
@@ -191,6 +191,6 @@ func (l Location) String() string {
func (l Location) Equals(other Location) bool {
return l.RealPath == other.RealPath &&
l.VirtualPath == other.VirtualPath &&
l.AccessPath == other.AccessPath &&
l.FileSystemID == other.FileSystemID
}