pkg/ioutils: remove crypto/sha256, crypto/sha512 imports

commit 572498be56 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 98caf09f0f.

[go-digest#64]: https://github.com/opencontainers/go-digest/pull/64

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-01-15 00:20:28 +01:00
parent a2b1ac7959
commit 3db60168e7

View File

@@ -2,10 +2,6 @@ package ioutils // import "github.com/docker/docker/pkg/ioutils"
import ( import (
"context" "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" "io"
"runtime/debug" "runtime/debug"
"sync/atomic" "sync/atomic"