Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeFileHash ¶
ComputeFileHashAtPath attempts to calculate the sha256 hash of a file (the file must already be opened).
func ComputeFileHashAtPath ¶
ComputeFileHashAtPath attempts to open a file at a path and calculate its sha256 hash.
func WithDigest ¶
With digest associates the key to a specific container digest, or to host.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache(mode config.CalcHashesOption, resolver pathResolver) (*Cache, error)
NewCache creates a new cache for storing sha256 hashes with associated files. In order to meet multiple performance and correctness needs, the cache can operate in multiple modes.
- inode: recalculates the file hash if the inode's creation time (ctime) differs. The option is performant, but not necessarily correct.
- dev-inode: generally offers better performance compared to the inode option, as it bypasses the need for recalculation by associating the creation time (ctime) with the device (dev) and inode pair. It's recommended if correctnes is preferred over performance without container enrichment.
- digest-inode: is the most efficient, as it keys the hash to a pair consisting of the container image digest and inode. This approach, however, necessitates container enrichment.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func NewKey ¶
NewKey creates a base key for usage with the file hash cache. It requires a filepath and mountns for the key as base information. Further information must be added through options.
func (*Key) DeviceKey ¶
DeviceKey returns a string key for the file's device and inode. Format is "device:ctime:inode".
func (*Key) DigestKey ¶
DigestKey returns a string key based on the file container origin(digest or host), and it's inode key. Format is "digest:ctime:inode".
func (*Key) InodeKey ¶
InodeKey returns a string key based on the file inode Format is "ctime:inode"