Documentation
¶
Index ¶
- func SupportedAlgorithms() iter.Seq[Algorithm]
- type Algorithm
- type Checksum
- type ChecksumCache
- func (c *ChecksumCache) FromChecksum(checksum Checksum) (Digest, bool)
- func (c *ChecksumCache) FromIntegrity(integrity Integrity) map[Algorithm]Digest
- func (c *ChecksumCache) FromIntegrityWithAlgorithm(integrity Integrity, digestFunction Algorithm) (Digest, bool)
- func (c *ChecksumCache) GetSlice(hash []byte, identifier byte) (Digest, bool)
- func (c *ChecksumCache) PutIntegrity(integrity Integrity, digest Digest)
- func (c *ChecksumCache) PutSlice(hash []byte, identifier byte, digest Digest)
- type Digest
- func (d Digest) CheckContent(r io.Reader, algorithm Algorithm) error
- func (d Digest) CopyHashInto(dest []byte, algorithm Algorithm) error
- func (d Digest) Equals(other Digest, algorithm Algorithm) bool
- func (d Digest) Hex(algorithm Algorithm) string
- func (d Digest) Uninitialized() bool
- func (d Digest) ZeroSized(algorithm Algorithm) bool
- type Integrity
- func (i Integrity) BestSingleChecksum(alg Algorithm) (Checksum, bool)
- func (i Integrity) ChecksumForAlgorithm(alg Algorithm) (Checksum, bool)
- func (i Integrity) Empty() bool
- func (i Integrity) Equivalent(other Integrity) bool
- func (i Integrity) Items() iter.Seq[Checksum]
- func (i Integrity) ToSRIList() []string
- func (i Integrity) ToSRIString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedAlgorithms ¶
Types ¶
type Algorithm ¶
type Algorithm struct {
// contains filtered or unexported fields
}
func AlgorithmFromString ¶
func (Algorithm) Identifier ¶
Identifier returns a unique byte identifier for the algorithm. It is used internally to identify the algorithm for caching.
type Checksum ¶
Checksum represents a single checksum of an artifact for a specific algorithm. It doesn't contain the size of the contents.
func ChecksumFromDigest ¶
type ChecksumCache ¶
type ChecksumCache struct {
// contains filtered or unexported fields
}
checksumCache contains a map of checksums to digests. The key can be of any hash function, as long as it can be padded to 64 bytes. One byte is reserved for the identifier of the checksum. The value is a digest (for the main digest function "--digest_function").
func NewCache ¶
func NewCache() *ChecksumCache
func (*ChecksumCache) FromChecksum ¶
func (c *ChecksumCache) FromChecksum(checksum Checksum) (Digest, bool)
func (*ChecksumCache) FromIntegrity ¶
func (c *ChecksumCache) FromIntegrity(integrity Integrity) map[Algorithm]Digest
func (*ChecksumCache) FromIntegrityWithAlgorithm ¶
func (c *ChecksumCache) FromIntegrityWithAlgorithm(integrity Integrity, digestFunction Algorithm) (Digest, bool)
func (*ChecksumCache) GetSlice ¶
func (c *ChecksumCache) GetSlice(hash []byte, identifier byte) (Digest, bool)
func (*ChecksumCache) PutIntegrity ¶
func (c *ChecksumCache) PutIntegrity(integrity Integrity, digest Digest)
type Digest ¶
type Digest struct {
// Size of the content in bytes.
SizeBytes int64
// contains filtered or unexported fields
}
Digest represents the digest of a blob in the Content Addressable Storage (CAS), as specified in the remote execution API, including the hash and content size (in bytes). Unlike the remote execution API, the hash is encoded as a byte array.
func DigestFromHex ¶
func (Digest) CopyHashInto ¶
CopyHashInto copies the hash into the destination buffer. The destination buffer must be at least the size of the hash.
func (Digest) Uninitialized ¶
type Integrity ¶
type Integrity struct {
// contains filtered or unexported fields
}
Integrity represents the integrity of an artifact, including checksums for multiple algorithms. This representation is not space-efficient, but it doesn't require additional allocations for each checksum. If the number of supported algorithms increases, this representation should be changed to a map.
func EmptyBlobIntegrity ¶
func EmptyBlobIntegrity() Integrity
func IntegrityFromChecksums ¶
func IntegrityFromContent ¶
func IntegrityFromString ¶
func (Integrity) BestSingleChecksum ¶
BestSingleChecksum returns the best single checksum (with preferrence for the given algorithm). Alternatively, other algorithms are allowed.
func (Integrity) ChecksumForAlgorithm ¶
func (Integrity) Equivalent ¶
Equivalent returns true if the two Integrity objects are equivalent. This means: for each algorithm that has a checksum in both objects, the checksums are equal. We also require that at least one checksum is present in both objects. Additionally, any object with no checksums is considered unequal to any other object.
func (Integrity) ToSRIList ¶
ToSRIList returns a list of Subresource Integrity (SRI) strings for the integrity. Each SRI string contains a single checksum.
func (Integrity) ToSRIString ¶
ToSRIString returns a single string with all Subresource Integrity (SRI) strings for the integrity. The checksums are separated by whitespace.