Skip to content

Commit 98caf09

Browse files
committed
fix go-digest to make sure the algorithms are registered
Previously, ioutils imported the crypty/sha256 package, because it was used by the HashData() utility. As a side-effect of that import, the sha256 algorithm was registered through its `init()` function. Now that the HashData() utility is removed, the import is no longer needed in this package, but some parts of our code depended on the side-effect, and without this, it fail to recognise the algorithms, unless something else happens to import crypto/sha256 / crypto/sha512, which made our tests fail: ``` === Failed === FAIL: reference TestLoad (0.00s) store_test.go:53: failed to parse reference: unsupported digest algorithm === FAIL: reference TestSave (0.00s) store_test.go:82: failed to parse reference: unsupported digest algorithm === FAIL: reference TestAddDeleteGet (0.00s) store_test.go:174: could not parse reference: unsupported digest algorithm === FAIL: reference TestInvalidTags (0.00s) store_test.go:355: assertion failed: error is not nil: unsupported digest algorithm ``` While it would be better to do the import in the actual locations where it's expected, there may be code-paths we overlook, so instead adding the import here temporarily. Until the PR in go-digest has been merged and released. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 572498b commit 98caf09

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/ioutils/readers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ package ioutils // import "github.com/docker/docker/pkg/ioutils"
33
import (
44
"context"
55
"io"
6+
7+
// make sure crypto.SHA256, crypto.sha512 and crypto.SHA384 are registered
8+
// TODO remove once https://github.com/opencontainers/go-digest/pull/64 is merged.
9+
_ "crypto/sha256"
10+
_ "crypto/sha512"
611
)
712

813
// ReadCloserWrapper wraps an io.Reader, and implements an io.ReadCloser

0 commit comments

Comments
 (0)