Remove uses of deprecated go-digest.NewDigestFromHex, go-digest.Digest.Hex

Both of these were deprecated in 55f675811a,
but the format of the GoDoc comments didn't follow the correct format, which
caused them not being picked up by tools as "deprecated".

This patch updates uses in the codebase to use the alternatives.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-11-08 14:47:05 +01:00
parent d1564fec5b
commit 717aa5929d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 5 additions and 5 deletions

View File

@ -262,7 +262,7 @@ func (s *store) Walk(ctx context.Context, fn content.WalkFunc, fs ...string) err
return nil
}
dgst := digest.NewDigestFromHex(alg.String(), filepath.Base(path))
dgst := digest.NewDigestFromEncoded(alg, filepath.Base(path))
if err := dgst.Validate(); err != nil {
// log error but don't report
log.L.WithError(err).WithField("path", path).Error("invalid digest for blob path")
@ -628,14 +628,14 @@ func (s *store) blobPath(dgst digest.Digest) (string, error) {
return "", fmt.Errorf("cannot calculate blob path from invalid digest: %v: %w", err, errdefs.ErrInvalidArgument)
}
return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Hex()), nil
return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Encoded()), nil
}
func (s *store) ingestRoot(ref string) string {
// we take a digest of the ref to keep the ingest paths constant length.
// Note that this is not the current or potential digest of incoming content.
dgst := digest.FromString(ref)
return filepath.Join(s.root, "ingest", dgst.Hex())
return filepath.Join(s.root, "ingest", dgst.Encoded())
}
// ingestPaths are returned. The paths are the following:

View File

@ -308,7 +308,7 @@ func checkBlobPath(t *testing.T, cs content.Store, dgst digest.Digest) string {
t.Fatalf("failed to calculate blob path: %v", err)
}
if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Hex()) {
if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Encoded()) {
t.Fatalf("unexpected path: %q", path)
}
fi, err := os.Stat(path)

View File

@ -40,7 +40,7 @@ func checkBlobPath(dgst digest.Digest, root string) error {
if err := dgst.Validate(); err != nil {
return err
}
path := filepath.Join(root, "blobs", dgst.Algorithm().String(), dgst.Hex())
path := filepath.Join(root, "blobs", dgst.Algorithm().String(), dgst.Encoded())
_, err := os.Stat(path)
if err != nil {
return err