mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 00:43:20 +01:00
* 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: <>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package file
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/anchore/syft/internal/log"
|
|
"github.com/anchore/syft/syft/artifact"
|
|
)
|
|
|
|
// Coordinates contains the minimal information needed to describe how to find a file within any possible source object (e.g. image and directory sources)
|
|
type Coordinates struct {
|
|
RealPath string `json:"path" cyclonedx:"path"` // The path where all path ancestors have no hardlinks / symlinks
|
|
FileSystemID string `json:"layerID,omitempty" cyclonedx:"layerID"` // An ID representing the filesystem. For container images, this is a layer digest. For directories or a root filesystem, this is blank.
|
|
}
|
|
|
|
func (c Coordinates) ID() artifact.ID {
|
|
f, err := artifact.IDByHash(c)
|
|
if err != nil {
|
|
// TODO: what to do in this case?
|
|
log.Warnf("unable to get fingerprint of location coordinate=%+v: %+v", c, err)
|
|
return ""
|
|
}
|
|
|
|
return f
|
|
}
|
|
|
|
func (c Coordinates) String() string {
|
|
str := fmt.Sprintf("RealPath=%q", c.RealPath)
|
|
|
|
if c.FileSystemID != "" {
|
|
str += fmt.Sprintf(" Layer=%q", c.FileSystemID)
|
|
}
|
|
return fmt.Sprintf("Location<%s>", str)
|
|
}
|