fix(provenance): Ports error check for Digest to v3

This is a port of #5672

Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
This commit is contained in:
Taylor Thomas 2019-09-24 13:59:14 -06:00
parent faa9048580
commit 9b87721c1f

View file

@ -402,6 +402,8 @@ func DigestFile(filename string) (string, error) {
// Helm uses SHA256 as its default hash for all non-cryptographic applications.
func Digest(in io.Reader) (string, error) {
hash := crypto.SHA256.New()
io.Copy(hash, in)
if _, err := io.Copy(hash, in); err != nil {
return "", nil
}
return hex.EncodeToString(hash.Sum(nil)), nil
}