Skip to content

Commit 319ac44

Browse files
committed
Add DigestIfAlgorithmUnknown
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
1 parent 979e9aa commit 319ac44

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

image/internal/putblobdigest/put_blob_digest.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ func DigestIfCanonicalUnknown(stream io.Reader, blobInfo types.BlobInfo) (Digest
4646
return newDigester(stream, d, d != "" && d.Algorithm() == digest.Canonical)
4747
}
4848

49+
// DigestIfAlgorithmUnknown initiates computation of a digest of stream,
50+
// if a digest of the specified algorithm is not supplied in the provided blobInfo;
51+
// otherwise blobInfo.Digest will be used.
52+
// The caller MUST use the returned stream instead of the original value.
53+
func DigestIfAlgorithmUnknown(stream io.Reader, blobInfo types.BlobInfo, algorithm digest.Algorithm) (Digester, io.Reader) {
54+
d := blobInfo.Digest
55+
return newDigester(stream, d, d != "" && d.Algorithm() == algorithm)
56+
}
57+
4958
// Digest() returns a digest value possibly computed by Digester.
5059
// This must be called only after all of the stream returned by a Digester constructor
5160
// has been successfully read.

0 commit comments

Comments
 (0)