-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
- Loading branch information
Showing
2 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package source | ||
|
||
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"` // The path where all path ancestors have no hardlinks / symlinks | ||
FileSystemID string `json:"layerID,omitempty"` // 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.IDFromHash(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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters