copy/copy.go
func newDigestingReader(source io.Reader, expectedDigest digest.Digest) (*digestingReader, error) {
	if err := expectedDigest.Validate(); err != nil {
		return nil, errors.Errorf("Invalid digest specification %s", expectedDigest)
	}
	digestAlgorithm := expectedDigest.Algorithm()
	if !digestAlgorithm.Available() {
		return nil, errors.Errorf("Invalid digest specification %s: unsupported digest algorithm %s", expectedDigest, digestAlgorithm)
	}
	return &digestingReader{
		source:           source,
		digester:         digestAlgorithm.Digester(),
		expectedDigest:   expectedDigest,
		validationFailed: false,
	}, nil
}
func newDigestingReader(source io.Reader, expectedDigest digest.Digest) (*digestingReader, error) {
	if err := expectedDigest.Validate(); err != nil {
		return nil, errors.Errorf("Invalid digest specification %s", expectedDigest)
	}
	digestAlgorithm := expectedDigest.Algorithm()
	if !digestAlgorithm.Available() {
		return nil, errors.Errorf("Invalid digest specification %s: unsupported digest algorithm %s", expectedDigest, digestAlgorithm)
	}
	return &digestingReader{
		source:           source,
		digester:         digestAlgorithm.Digester(),
		expectedDigest:   expectedDigest,
		validationFailed: false,
	}, nil
}
func newDigestingReader ( source io . Reader , expectedDigest digest . Digest ) ( * digestingReader , error ) { if err := expectedDigest . Validate ( ) ; err != nil { return nil , errors . Errorf ( " " , expectedDigest ) } digestAlgorithm := expectedDigest . Algorithm ( ) if ! digestAlgorithm . Available ( ) { return nil , errors . Errorf ( " " , expectedDigest , digestAlgorithm ) } return & digestingReader { source : source , digester : digestAlgorithm . Digester ( ) , expectedDigest : expectedDigest , validationFailed : false , } , nil }
// newDigestingReader returns an io.Reader implementation with contents of source, which will eventually return a non-EOF error
// or set validationSucceeded/validationFailed to true if the source stream does/does not match expectedDigest.
// (neither is set if EOF is never reached).
newDigestingReader returns an io . Reader implementation with contents of source which will eventually return a non - EOF error or set validationSucceeded / validationFailed to true if the source stream does / does not match expectedDigest . ( neither is set if EOF is never reached ) .