mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
feat(api): added oci-subject header when pushing an image with subject field (#1415)
- as requested by the latest version of the oci distribution spec Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
@@ -52,7 +52,7 @@ func generateTestImage(storeController storage.StoreController, image string) {
|
||||
|
||||
manifestBlob, err := json.Marshal(manifest)
|
||||
So(err, ShouldBeNil)
|
||||
_, err = store.PutImageManifest(repoName, tag, ispec.MediaTypeImageManifest, manifestBlob)
|
||||
_, _, err = store.PutImageManifest(repoName, tag, ispec.MediaTypeImageManifest, manifestBlob)
|
||||
So(err, ShouldBeNil)
|
||||
}
|
||||
|
||||
|
||||
@@ -4515,8 +4515,10 @@ func TestRepoDBWhenSigningImages(t *testing.T) {
|
||||
Convey("imageIsSignature fails", func() {
|
||||
// make image store ignore the wrong format of the input
|
||||
ctlr.StoreController.DefaultStore = mocks.MockedImageStore{
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest, error) {
|
||||
return "", nil
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
},
|
||||
DeleteImageManifestFn: func(repo, reference string, dc bool) error {
|
||||
return ErrTestError
|
||||
@@ -5783,8 +5785,10 @@ func TestRepoDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
Convey("imageIsSignature fails", func() {
|
||||
ctlr.StoreController.DefaultStore = mocks.MockedImageStore{
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest, error) {
|
||||
return "", nil
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
},
|
||||
DeleteImageManifestFn: func(repo, reference string, dc bool) error {
|
||||
return nil
|
||||
@@ -5807,8 +5811,10 @@ func TestRepoDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
return configBlob, nil
|
||||
},
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest, error) {
|
||||
return "", nil
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
},
|
||||
DeleteImageManifestFn: func(repo, reference string, dc bool) error {
|
||||
return nil
|
||||
@@ -5835,8 +5841,10 @@ func TestRepoDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
return configBlob, nil
|
||||
},
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest, error) {
|
||||
return "", ErrTestError
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", ErrTestError
|
||||
},
|
||||
DeleteImageManifestFn: func(repo, reference string, dc bool) error {
|
||||
return nil
|
||||
|
||||
@@ -180,7 +180,7 @@ func (sig *signaturesCopier) syncCosignSignature(localRepo, remoteRepo, digestSt
|
||||
}
|
||||
|
||||
// push manifest
|
||||
_, err = imageStore.PutImageManifest(localRepo, cosignTag,
|
||||
_, _, err = imageStore.PutImageManifest(localRepo, cosignTag,
|
||||
ispec.MediaTypeImageManifest, cosignManifestBuf)
|
||||
if err != nil {
|
||||
sig.log.Error().Str("errorType", common.TypeOf(err)).
|
||||
@@ -258,7 +258,7 @@ func (sig *signaturesCopier) syncORASRefs(localRepo, remoteRepo, digestStr strin
|
||||
}
|
||||
}
|
||||
|
||||
_, err = imageStore.PutImageManifest(localRepo, ref.Digest.String(),
|
||||
_, _, err = imageStore.PutImageManifest(localRepo, ref.Digest.String(),
|
||||
oras.MediaTypeArtifactManifest, body)
|
||||
if err != nil {
|
||||
sig.log.Error().Str("errorType", common.TypeOf(err)).
|
||||
@@ -359,7 +359,7 @@ func (sig *signaturesCopier) syncOCIRefs(localRepo, remoteRepo, digestStr string
|
||||
continue
|
||||
}
|
||||
|
||||
digest, err := imageStore.PutImageManifest(localRepo, ref.Digest.String(),
|
||||
digest, _, err := imageStore.PutImageManifest(localRepo, ref.Digest.String(),
|
||||
ref.MediaType, OCIRefBody)
|
||||
if err != nil {
|
||||
sig.log.Error().Str("errorType", common.TypeOf(err)).
|
||||
|
||||
@@ -698,7 +698,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
|
||||
manifestDigest := godigest.FromBytes(manifestContent)
|
||||
|
||||
_, err = testImageStore.PutImageManifest(repo, manifestDigest.String(),
|
||||
_, _, err = testImageStore.PutImageManifest(repo, manifestDigest.String(),
|
||||
ispec.MediaTypeImageManifest, manifestContent)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
@@ -715,7 +715,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
So(digest, ShouldNotBeNil)
|
||||
|
||||
// upload index image
|
||||
_, err = testImageStore.PutImageManifest(repo, "latest", ispec.MediaTypeImageIndex, content)
|
||||
_, _, err = testImageStore.PutImageManifest(repo, "latest", ispec.MediaTypeImageIndex, content)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
err = pushSyncedLocalImage(repo, "latest", testRootDir, nil, imageStore, log)
|
||||
|
||||
@@ -337,7 +337,7 @@ func pushSyncedLocalImage(localRepo, reference, localCachePath string,
|
||||
}
|
||||
}
|
||||
|
||||
_, err = imageStore.PutImageManifest(localRepo, reference, mediaType, manifestBlob)
|
||||
_, _, err = imageStore.PutImageManifest(localRepo, reference, mediaType, manifestBlob)
|
||||
if err != nil {
|
||||
log.Error().Str("errorType", common.TypeOf(err)).
|
||||
Err(err).Msg("couldn't upload manifest")
|
||||
@@ -393,7 +393,7 @@ func copyManifest(localRepo string, manifestContent []byte, reference string, re
|
||||
return err
|
||||
}
|
||||
|
||||
digest, err := imageStore.PutImageManifest(localRepo, reference,
|
||||
digest, _, err := imageStore.PutImageManifest(localRepo, reference,
|
||||
ispec.MediaTypeImageManifest, manifestContent)
|
||||
if err != nil {
|
||||
log.Error().Str("errorType", common.TypeOf(err)).
|
||||
|
||||
Reference in New Issue
Block a user