github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/file/coordinates.go (about) 1 package file 2 3 import ( 4 "fmt" 5 6 "github.com/anchore/syft/internal/log" 7 "github.com/anchore/syft/syft/artifact" 8 ) 9 10 // Coordinates contains the minimal information needed to describe how to find a file within any possible source object (e.g. image and directory sources) 11 type Coordinates struct { 12 RealPath string `json:"path" cyclonedx:"path"` // The path where all path ancestors have no hardlinks / symlinks 13 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. 14 } 15 16 func (c Coordinates) ID() artifact.ID { 17 f, err := artifact.IDByHash(c) 18 if err != nil { 19 // TODO: what to do in this case? 20 log.Warnf("unable to get fingerprint of location coordinate=%+v: %+v", c, err) 21 return "" 22 } 23 24 return f 25 } 26 27 func (c Coordinates) String() string { 28 str := fmt.Sprintf("RealPath=%q", c.RealPath) 29 30 if c.FileSystemID != "" { 31 str += fmt.Sprintf(" Layer=%q", c.FileSystemID) 32 } 33 return fmt.Sprintf("Location<%s>", str) 34 }