Add generic content digest tool
Previously a useful gist, this changeset polishes the original tarsum tool into a utility that can be used to calculate content digests. Any algorithm from the digest package is supported with additional support from tarsum. This tool is very useful for quickly checking backend digests and verifying correctness. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -70,15 +70,10 @@ func ParseDigest(s string) (Digest, error) {
|
||||
return d, d.Validate()
|
||||
}
|
||||
|
||||
// FromReader returns the most valid digest for the underlying content.
|
||||
// FromReader returns the most valid digest for the underlying content using
|
||||
// the canonical digest algorithm.
|
||||
func FromReader(rd io.Reader) (Digest, error) {
|
||||
digester := Canonical.New()
|
||||
|
||||
if _, err := io.Copy(digester.Hash(), rd); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return digester.Digest(), nil
|
||||
return Canonical.FromReader(rd)
|
||||
}
|
||||
|
||||
// FromTarArchive produces a tarsum digest from reader rd.
|
||||
|
Reference in New Issue
Block a user