From 3db60168e7fa8b1a9a4ad35c2b9abd085d095e4b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 15 Jan 2025 00:20:28 +0100 Subject: [PATCH] pkg/ioutils: remove crypto/sha256, crypto/sha512 imports commit 572498be565ab8312e2b2b721f252cc5b38c470e moved the ioutils.HashData utility to the libnetwork resolvconf package. After removing, we saw some tests in the reference pacakge failing; === 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 Those failures were because those tests depended on a side-effect of the ioutils package being imported, which (before removal of HashData) imported crypto/sha256, registering that algorithms, which on its turn was used by github.com/opencontainers/go-digest to determnin if a given algorithm must be accepted (see [go-digest#64]). As a workaround, these imports were added. pkg/ioutils is now imported in less places, and should not be depended on for this purpose. Let's remove this workaround; if needed, these imports can be added in a more relevant location. This reverts commit 98caf09f0ff46f96018d94e63eb25da5faa155d2. [go-digest#64]: https://github.com/opencontainers/go-digest/pull/64 Signed-off-by: Sebastiaan van Stijn --- pkg/ioutils/readers.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/ioutils/readers.go b/pkg/ioutils/readers.go index 298ac9b3a3..9ddba2468d 100644 --- a/pkg/ioutils/readers.go +++ b/pkg/ioutils/readers.go @@ -2,10 +2,6 @@ package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "context" - // make sure crypto.SHA256, crypto.sha512 and crypto.SHA384 are registered - // TODO remove once https://github.com/opencontainers/go-digest/pull/64 is merged. - _ "crypto/sha256" - _ "crypto/sha512" "io" "runtime/debug" "sync/atomic"