Both of these were deprecated in https://github.com/opencontainers/go-digest/commit/55f675811a1b915549933c64571fd86b2676ba76,
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>
| ... | ... |
@@ -117,11 +117,11 @@ func (serv *v2MetadataService) digestNamespace() string {
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 | 119 |
func (serv *v2MetadataService) diffIDKey(diffID layer.DiffID) string {
|
| 120 |
- return string(digest.Digest(diffID).Algorithm()) + "/" + digest.Digest(diffID).Hex() |
|
| 120 |
+ return string(digest.Digest(diffID).Algorithm()) + "/" + digest.Digest(diffID).Encoded() |
|
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 | 123 |
func (serv *v2MetadataService) digestKey(dgst digest.Digest) string {
|
| 124 |
- return string(dgst.Algorithm()) + "/" + dgst.Hex() |
|
| 124 |
+ return string(dgst.Algorithm()) + "/" + dgst.Encoded() |
|
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 | 127 |
// GetMetadata finds the metadata associated with a layer DiffID. |
| ... | ... |
@@ -56,11 +56,11 @@ func newFSStore(root string) (*fs, error) {
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 | 58 |
func (s *fs) contentFile(dgst digest.Digest) string {
|
| 59 |
- return filepath.Join(s.root, contentDirName, string(dgst.Algorithm()), dgst.Hex()) |
|
| 59 |
+ return filepath.Join(s.root, contentDirName, string(dgst.Algorithm()), dgst.Encoded()) |
|
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 | 62 |
func (s *fs) metadataDir(dgst digest.Digest) string {
|
| 63 |
- return filepath.Join(s.root, metadataDirName, string(dgst.Algorithm()), dgst.Hex()) |
|
| 63 |
+ return filepath.Join(s.root, metadataDirName, string(dgst.Algorithm()), dgst.Encoded()) |
|
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 | 66 |
// Walk calls the supplied callback for each image ID in the storage backend. |
| ... | ... |
@@ -73,7 +73,7 @@ func (s *fs) Walk(f DigestWalkFunc) error {
|
| 73 | 73 |
return err |
| 74 | 74 |
} |
| 75 | 75 |
for _, v := range dir {
|
| 76 |
- dgst := digest.NewDigestFromHex(string(digest.Canonical), v.Name()) |
|
| 76 |
+ dgst := digest.NewDigestFromEncoded(digest.Canonical, v.Name()) |
|
| 77 | 77 |
if err := dgst.Validate(); err != nil {
|
| 78 | 78 |
logrus.Debugf("skipping invalid digest %s: %s", dgst, err)
|
| 79 | 79 |
continue |
| ... | ... |
@@ -31,7 +31,7 @@ func TestFSGetInvalidData(t *testing.T) {
|
| 31 | 31 |
dgst, err := store.Set([]byte("foobar"))
|
| 32 | 32 |
assert.Check(t, err) |
| 33 | 33 |
|
| 34 |
- err = os.WriteFile(filepath.Join(store.(*fs).root, contentDirName, string(dgst.Algorithm()), dgst.Hex()), []byte("foobar2"), 0600)
|
|
| 34 |
+ err = os.WriteFile(filepath.Join(store.(*fs).root, contentDirName, string(dgst.Algorithm()), dgst.Encoded()), []byte("foobar2"), 0o600)
|
|
| 35 | 35 |
assert.Check(t, err) |
| 36 | 36 |
|
| 37 | 37 |
_, err = store.Get(dgst) |
| ... | ... |
@@ -43,7 +43,7 @@ func TestFSInvalidSet(t *testing.T) {
|
| 43 | 43 |
defer cleanup() |
| 44 | 44 |
|
| 45 | 45 |
id := digest.FromBytes([]byte("foobar"))
|
| 46 |
- err := os.Mkdir(filepath.Join(store.(*fs).root, contentDirName, string(id.Algorithm()), id.Hex()), 0700) |
|
| 46 |
+ err := os.Mkdir(filepath.Join(store.(*fs).root, contentDirName, string(id.Algorithm()), id.Encoded()), 0o700) |
|
| 47 | 47 |
assert.Check(t, err) |
| 48 | 48 |
|
| 49 | 49 |
_, err = store.Set([]byte("foobar"))
|
| ... | ... |
@@ -64,11 +64,11 @@ func TestRestore(t *testing.T) {
|
| 64 | 64 |
assert.NilError(t, err) |
| 65 | 65 |
assert.Check(t, is.Equal(ID(id1), sid1)) |
| 66 | 66 |
|
| 67 |
- sid1, err = imgStore.Search(id1.Hex()[:6]) |
|
| 67 |
+ sid1, err = imgStore.Search(id1.Encoded()[:6]) |
|
| 68 | 68 |
assert.NilError(t, err) |
| 69 | 69 |
assert.Check(t, is.Equal(ID(id1), sid1)) |
| 70 | 70 |
|
| 71 |
- invalidPattern := id1.Hex()[1:6] |
|
| 71 |
+ invalidPattern := id1.Encoded()[1:6] |
|
| 72 | 72 |
_, err = imgStore.Search(invalidPattern) |
| 73 | 73 |
assert.ErrorContains(t, err, "No such image") |
| 74 | 74 |
} |
| ... | ... |
@@ -216,7 +216,7 @@ func (s *saveSession) save(outStream io.Writer) error {
|
| 216 | 216 |
} |
| 217 | 217 |
|
| 218 | 218 |
manifest = append(manifest, manifestItem{
|
| 219 |
- Config: id.Digest().Hex() + ".json", |
|
| 219 |
+ Config: id.Digest().Encoded() + ".json", |
|
| 220 | 220 |
RepoTags: repoTags, |
| 221 | 221 |
Layers: layers, |
| 222 | 222 |
LayerSources: foreignSrcs, |
| ... | ... |
@@ -304,9 +304,9 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc |
| 304 | 304 |
return nil, err |
| 305 | 305 |
} |
| 306 | 306 |
|
| 307 |
- v1Img.ID = v1ID.Hex() |
|
| 307 |
+ v1Img.ID = v1ID.Encoded() |
|
| 308 | 308 |
if parent != "" {
|
| 309 |
- v1Img.Parent = parent.Hex() |
|
| 309 |
+ v1Img.Parent = parent.Encoded() |
|
| 310 | 310 |
} |
| 311 | 311 |
|
| 312 | 312 |
v1Img.OS = img.OS |
| ... | ... |
@@ -324,8 +324,8 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc |
| 324 | 324 |
} |
| 325 | 325 |
} |
| 326 | 326 |
|
| 327 |
- configFile := filepath.Join(s.outDir, id.Digest().Hex()+".json") |
|
| 328 |
- if err := os.WriteFile(configFile, img.RawJSON(), 0644); err != nil {
|
|
| 327 |
+ configFile := filepath.Join(s.outDir, id.Digest().Encoded()+".json") |
|
| 328 |
+ if err := os.WriteFile(configFile, img.RawJSON(), 0o644); err != nil {
|
|
| 329 | 329 |
return nil, err |
| 330 | 330 |
} |
| 331 | 331 |
if err := system.Chtimes(configFile, img.Created, img.Created); err != nil {
|
| ... | ... |
@@ -323,7 +323,7 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
|
| 323 | 323 |
assert.NilError(c, err, "error marshalling manifest list") |
| 324 | 324 |
|
| 325 | 325 |
manifestListDigest := digest.FromBytes(manifestListJSON) |
| 326 |
- hexDigest := manifestListDigest.Hex() |
|
| 326 |
+ hexDigest := manifestListDigest.Encoded() |
|
| 327 | 327 |
|
| 328 | 328 |
registryV2Path := s.reg.Path() |
| 329 | 329 |
|
| ... | ... |
@@ -123,7 +123,7 @@ func (s *DockerCLISaveLoadSuite) TestSaveCheckTimes(c *testing.T) {
|
| 123 | 123 |
out, err = RunCommandPipelineWithOutput( |
| 124 | 124 |
exec.Command(dockerBinary, "save", repoName), |
| 125 | 125 |
exec.Command("tar", "tv"),
|
| 126 |
- exec.Command("grep", "-E", fmt.Sprintf("%s %s", data[0].Created.Format(tarTvTimeFormat), digest.Digest(data[0].ID).Hex())))
|
|
| 126 |
+ exec.Command("grep", "-E", fmt.Sprintf("%s %s", data[0].Created.Format(tarTvTimeFormat), digest.Digest(data[0].ID).Encoded())))
|
|
| 127 | 127 |
assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) |
| 128 | 128 |
} |
| 129 | 129 |
|
| ... | ... |
@@ -258,7 +258,7 @@ func (s *DockerCLISaveLoadSuite) TestSaveRepoWithMultipleImages(c *testing.T) {
|
| 258 | 258 |
|
| 259 | 259 |
// prefixes are not in tar |
| 260 | 260 |
for i := range expected {
|
| 261 |
- expected[i] = digest.Digest(expected[i]).Hex() |
|
| 261 |
+ expected[i] = digest.Digest(expected[i]).Encoded() |
|
| 262 | 262 |
} |
| 263 | 263 |
|
| 264 | 264 |
sort.Strings(actual) |
| ... | ... |
@@ -49,7 +49,7 @@ func newFSMetadataStore(root string) (*fileMetadataStore, error) {
|
| 49 | 49 |
|
| 50 | 50 |
func (fms *fileMetadataStore) getLayerDirectory(layer ChainID) string {
|
| 51 | 51 |
dgst := digest.Digest(layer) |
| 52 |
- return filepath.Join(fms.root, string(dgst.Algorithm()), dgst.Hex()) |
|
| 52 |
+ return filepath.Join(fms.root, string(dgst.Algorithm()), dgst.Encoded()) |
|
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
func (fms *fileMetadataStore) getLayerFilename(layer ChainID, filename string) string {
|
| ... | ... |
@@ -364,7 +364,7 @@ func (fms *fileMetadataStore) List() ([]ChainID, []string, error) {
|
| 364 | 364 |
|
| 365 | 365 |
for _, fi := range fileInfos {
|
| 366 | 366 |
if fi.IsDir() && fi.Name() != "mounts" {
|
| 367 |
- dgst := digest.NewDigestFromHex(string(algorithm), fi.Name()) |
|
| 367 |
+ dgst := digest.NewDigestFromEncoded(algorithm, fi.Name()) |
|
| 368 | 368 |
if err := dgst.Validate(); err != nil {
|
| 369 | 369 |
logrus.Debugf("Ignoring invalid digest %s:%s", algorithm, fi.Name())
|
| 370 | 370 |
} else {
|
| ... | ... |
@@ -397,7 +397,7 @@ func (ls *layerStore) deleteLayer(layer *roLayer, metadata *Metadata) error {
|
| 397 | 397 |
var dir string |
| 398 | 398 |
for {
|
| 399 | 399 |
dgst := digest.Digest(layer.chainID) |
| 400 |
- tmpID := fmt.Sprintf("%s-%s-removing", dgst.Hex(), stringid.GenerateRandomID())
|
|
| 400 |
+ tmpID := fmt.Sprintf("%s-%s-removing", dgst.Encoded(), stringid.GenerateRandomID())
|
|
| 401 | 401 |
dir = filepath.Join(ls.store.root, string(dgst.Algorithm()), tmpID) |
| 402 | 402 |
err := os.Rename(ls.store.getLayerDirectory(layer.chainID), dir) |
| 403 | 403 |
if os.IsExist(err) {
|
| ... | ... |
@@ -717,13 +717,13 @@ func TestTarStreamVerification(t *testing.T) {
|
| 717 | 717 |
id2 := digest.Digest(layer2.ChainID()) |
| 718 | 718 |
|
| 719 | 719 |
// Replace tar data files |
| 720 |
- src, err := os.Open(filepath.Join(tmpdir, id1.Algorithm().String(), id1.Hex(), "tar-split.json.gz")) |
|
| 720 |
+ src, err := os.Open(filepath.Join(tmpdir, id1.Algorithm().String(), id1.Encoded(), "tar-split.json.gz")) |
|
| 721 | 721 |
if err != nil {
|
| 722 | 722 |
t.Fatal(err) |
| 723 | 723 |
} |
| 724 | 724 |
defer src.Close() |
| 725 | 725 |
|
| 726 |
- dst, err := os.Create(filepath.Join(tmpdir, id2.Algorithm().String(), id2.Hex(), "tar-split.json.gz")) |
|
| 726 |
+ dst, err := os.Create(filepath.Join(tmpdir, id2.Algorithm().String(), id2.Encoded(), "tar-split.json.gz")) |
|
| 727 | 727 |
if err != nil {
|
| 728 | 728 |
t.Fatal(err) |
| 729 | 729 |
} |
| ... | ... |
@@ -171,7 +171,7 @@ func (r *V2) Close() {
|
| 171 | 171 |
|
| 172 | 172 |
func (r *V2) getBlobFilename(blobDigest digest.Digest) string {
|
| 173 | 173 |
// Split the digest into its algorithm and hex components. |
| 174 |
- dgstAlg, dgstHex := blobDigest.Algorithm(), blobDigest.Hex() |
|
| 174 |
+ dgstAlg, dgstHex := blobDigest.Algorithm(), blobDigest.Encoded() |
|
| 175 | 175 |
|
| 176 | 176 |
// The path to the target blob data looks something like: |
| 177 | 177 |
// baseDir + "docker/registry/v2/blobs/sha256/a3/a3ed...46d4/data" |