mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
refactor(digests): standardise representation of digests to digest.Digest (#898)
- Digests were represented by different ways
- We needed a uniform way to represent the digests and enforce a format
- also replace usage of github.com/google/go-containerregistry/pkg/v1
with github.com/opencontainers/image-spec/specs-go/v1
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
(cherry picked from commit 96b2f29d6d57070a913ce419149cd481c0723815)
(cherry picked from commit 3d41b583daea654c98378ce3dcb78937d71538e8)
Co-authored-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
@@ -374,14 +374,14 @@ func TestSyncInternal(t *testing.T) {
|
||||
|
||||
sig := newSignaturesCopier(resty.New(), *regURL, storage.StoreController{DefaultStore: imageStore}, log)
|
||||
|
||||
canBeSkipped, err = sig.canSkipNotarySignature(testImage, testImageManifestDigest, refs)
|
||||
canBeSkipped, err = sig.canSkipNotarySignature(testImage, testImageManifestDigest.String(), refs)
|
||||
So(err, ShouldBeNil)
|
||||
So(canBeSkipped, ShouldBeFalse)
|
||||
|
||||
err = os.Chmod(path.Join(imageStore.RootDir(), testImage, "index.json"), 0o000)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
canBeSkipped, err = sig.canSkipNotarySignature(testImage, testImageManifestDigest, refs)
|
||||
canBeSkipped, err = sig.canSkipNotarySignature(testImage, testImageManifestDigest.String(), refs)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(canBeSkipped, ShouldBeFalse)
|
||||
|
||||
@@ -392,7 +392,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
err = os.Chmod(path.Join(imageStore.RootDir(), testImage, "index.json"), 0o755)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
canBeSkipped, err = sig.canSkipCosignSignature(testImage, testImageManifestDigest, &cosignManifest)
|
||||
canBeSkipped, err = sig.canSkipCosignSignature(testImage, testImageManifestDigest.String(), &cosignManifest)
|
||||
So(err, ShouldBeNil)
|
||||
So(canBeSkipped, ShouldBeFalse)
|
||||
})
|
||||
@@ -480,7 +480,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
|
||||
for _, layer := range layers {
|
||||
// upload layer
|
||||
_, _, err := testImageStore.FullBlobUpload(repo, bytes.NewReader(layer), godigest.FromBytes(layer).String())
|
||||
_, _, err := testImageStore.FullBlobUpload(repo, bytes.NewReader(layer), godigest.FromBytes(layer))
|
||||
So(err, ShouldBeNil)
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
|
||||
configDigest := godigest.FromBytes(configContent)
|
||||
|
||||
_, _, err = testImageStore.FullBlobUpload(repo, bytes.NewReader(configContent), configDigest.String())
|
||||
_, _, err = testImageStore.FullBlobUpload(repo, bytes.NewReader(configContent), configDigest)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
manifestContent, err := json.Marshal(manifest)
|
||||
@@ -612,7 +612,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
}
|
||||
|
||||
if err := os.Chmod(path.Join(testRootDir, testImage, "blobs", "sha256",
|
||||
manifest.Layers[0].Digest.Hex()), 0o000); err != nil {
|
||||
manifest.Layers[0].Digest.Encoded()), 0o000); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -620,12 +620,12 @@ func TestSyncInternal(t *testing.T) {
|
||||
So(err, ShouldNotBeNil)
|
||||
|
||||
if err := os.Chmod(path.Join(testRootDir, testImage, "blobs", "sha256",
|
||||
manifest.Layers[0].Digest.Hex()), 0o755); err != nil {
|
||||
manifest.Layers[0].Digest.Encoded()), 0o755); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cachedManifestConfigPath := path.Join(imageStore.RootDir(), testImage, SyncBlobUploadDir,
|
||||
testImage, "blobs", "sha256", manifest.Config.Digest.Hex())
|
||||
testImage, "blobs", "sha256", manifest.Config.Digest.Encoded())
|
||||
if err := os.Chmod(cachedManifestConfigPath, 0o000); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user