mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
feat: support pushing multiple tags for a single manifest (#3885)
* feat: support pushing multiple tags for a single manifest See https://github.com/opencontainers/distribution-spec/pull/600 Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> * fix: constants not replaced in swagger output Also godot mandates comments ending in dots, which produces bad results in the swagger generated files, see the extra ". which is now fixed below: ``` diff --git a/swagger/docs.go b/swagger/docs.go index 84b08277..fb2c45c3 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -114,7 +114,7 @@ const docTemplate = `{ } }, "400": { - "description": "bad request\".", + "description": "bad request", "schema": { "type": "string" } @@ -200,7 +200,7 @@ const docTemplate = `{ } }, "400": { - "description": "bad request\".", + "description": "bad request", "schema": { "type": "string" } diff --git a/swagger/swagger.json b/swagger/swagger.json index cfeb3900..247f95fa 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -106,7 +106,7 @@ } }, "400": { - "description": "bad request\".", + "description": "bad request", "schema": { "type": "string" } @@ -192,7 +192,7 @@ } }, "400": { - "description": "bad request\".", + "description": "bad request", "schema": { "type": "string" } diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 57641c2f..09b30dcc 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -310,7 +310,7 @@ paths: schema: type: string "400": - description: bad request". + description: bad request schema: type: string "500": @@ -366,7 +366,7 @@ paths: schema: type: string "400": - description: bad request". + description: bad request schema: type: string "500": ``` Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> --------- Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
@@ -81,8 +81,8 @@ type ImageTrust struct {
|
||||
// @Produce json
|
||||
// @Param requestBody body string true "Public key content"
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Failure 400 {string} string "bad request".
|
||||
// @Failure 500 {string} string "internal server error".
|
||||
// @Failure 400 {string} string "bad request"
|
||||
// @Failure 500 {string} string "internal server error"
|
||||
func (trust *ImageTrust) HandleCosignPublicKeyUpload(response http.ResponseWriter, request *http.Request) {
|
||||
body, err := io.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
@@ -116,8 +116,8 @@ func (trust *ImageTrust) HandleCosignPublicKeyUpload(response http.ResponseWrite
|
||||
// @Param truststoreType query string false "truststore type"
|
||||
// @Param requestBody body string true "Certificate content"
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Failure 400 {string} string "bad request".
|
||||
// @Failure 500 {string} string "internal server error".
|
||||
// @Failure 400 {string} string "bad request"
|
||||
// @Failure 500 {string} string "internal server error"
|
||||
func (trust *ImageTrust) HandleNotationCertificateUpload(response http.ResponseWriter, request *http.Request) {
|
||||
var truststoreType string
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ type Mgmt struct {
|
||||
// @Produce json
|
||||
// @Param resource query string false "specify resource" Enums(config)
|
||||
// @Success 200 {object} extensions.StrippedConfig
|
||||
// @Failure 500 {string} string "internal server error".
|
||||
// @Failure 500 {string} string "internal server error"
|
||||
func (mgmt *Mgmt) HandleGetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
sanitizedConfig := mgmt.Conf.Sanitize()
|
||||
|
||||
|
||||
@@ -4271,7 +4271,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
indexMultiArchMiddle1Digest, _, err := storeCtlr.GetDefaultImageStore().PutImageManifest(repoName,
|
||||
"multiArchMiddle1", ispec.MediaTypeImageIndex, indexMultiArchMiddle1Blob)
|
||||
"multiArchMiddle1", ispec.MediaTypeImageIndex, indexMultiArchMiddle1Blob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
image211 := CreateRandomImage()
|
||||
@@ -4296,7 +4296,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
indexMultiArchMiddle2Digest, _, err := storeCtlr.GetDefaultImageStore().PutImageManifest(repoName,
|
||||
"multiArchMiddle2", ispec.MediaTypeImageIndex, indexMultiArchMiddle2Blob)
|
||||
"multiArchMiddle2", ispec.MediaTypeImageIndex, indexMultiArchMiddle2Blob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
image31 := CreateRandomImage()
|
||||
@@ -4331,7 +4331,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
_, _, err = storeCtlr.GetDefaultImageStore().PutImageManifest(repoName, "multiArchTop", ispec.MediaTypeImageIndex,
|
||||
indexMultiArchTopBlob)
|
||||
indexMultiArchTopBlob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
ctlrManager.StartAndWait(port)
|
||||
@@ -4443,7 +4443,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
indexMultiArchMiddle1Digest, _, err := storeCtlr.GetDefaultImageStore().PutImageManifest(repoName,
|
||||
"multiArchMiddle1", ispec.MediaTypeImageIndex, indexMultiArchMiddle1Blob)
|
||||
"multiArchMiddle1", ispec.MediaTypeImageIndex, indexMultiArchMiddle1Blob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
image211 := CreateRandomImage()
|
||||
@@ -4468,7 +4468,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
indexMultiArchMiddle2Digest, _, err := storeCtlr.GetDefaultImageStore().PutImageManifest(repoName,
|
||||
"multiArchMiddle2", ispec.MediaTypeImageIndex, indexMultiArchMiddle2Blob)
|
||||
"multiArchMiddle2", ispec.MediaTypeImageIndex, indexMultiArchMiddle2Blob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
image31 := CreateRandomImage()
|
||||
@@ -4503,7 +4503,7 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
_, _, err = storeCtlr.GetDefaultImageStore().PutImageManifest(repoName, "multiArchTop", ispec.MediaTypeImageIndex,
|
||||
indexMultiArchTopBlob)
|
||||
indexMultiArchTopBlob, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
ctlr := api.NewController(conf)
|
||||
@@ -5229,7 +5229,7 @@ func TestMetaDBWhenSigningImages(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,
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte, _ []string) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
@@ -6626,7 +6626,7 @@ func TestMetaDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
Convey("imageIsSignature fails", func() {
|
||||
ctlr.StoreController.DefaultStore = mocks.MockedImageStore{
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte, _ []string) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
@@ -6652,7 +6652,7 @@ func TestMetaDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
return configBlob, nil
|
||||
},
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte, _ []string) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", nil
|
||||
@@ -6682,7 +6682,7 @@ func TestMetaDBWhenDeletingImages(t *testing.T) {
|
||||
|
||||
return configBlob, nil
|
||||
},
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte) (godigest.Digest,
|
||||
PutImageManifestFn: func(repo, reference, mediaType string, body []byte, _ []string) (godigest.Digest,
|
||||
godigest.Digest, error,
|
||||
) {
|
||||
return "", "", ErrTestError
|
||||
|
||||
@@ -218,7 +218,7 @@ func (registry *DestinationRegistry) copyManifest(repo string, desc ispec.Descri
|
||||
}
|
||||
|
||||
digest, _, err := imageStore.PutImageManifest(repo, reference,
|
||||
desc.MediaType, manifestContent)
|
||||
desc.MediaType, manifestContent, nil)
|
||||
if err != nil {
|
||||
registry.log.Error().Str("errorType", common.TypeOf(err)).
|
||||
Err(err).Msg("couldn't upload manifest")
|
||||
@@ -299,7 +299,7 @@ func (registry *DestinationRegistry) copyManifest(repo string, desc ispec.Descri
|
||||
return firstMissingErr
|
||||
}
|
||||
|
||||
_, _, err := imageStore.PutImageManifest(repo, reference, desc.MediaType, manifestContent)
|
||||
_, _, err := imageStore.PutImageManifest(repo, reference, desc.MediaType, manifestContent, nil)
|
||||
if err != nil {
|
||||
registry.log.Error().Str("errorType", common.TypeOf(err)).Str("repo", repo).Str("reference", reference).
|
||||
Err(err).Msg("failed to upload manifest")
|
||||
|
||||
@@ -864,7 +864,7 @@ func TestDestinationRegistry(t *testing.T) {
|
||||
So(err, ShouldBeNil)
|
||||
digest = godigest.FromBytes(content)
|
||||
So(digest, ShouldNotBeNil)
|
||||
_, _, err = imgStore.PutImageManifest(repoName, digest.String(), ispec.MediaTypeImageManifest, content)
|
||||
_, _, err = imgStore.PutImageManifest(repoName, digest.String(), ispec.MediaTypeImageManifest, content, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
index.Manifests = append(index.Manifests, ispec.Descriptor{
|
||||
@@ -880,7 +880,7 @@ func TestDestinationRegistry(t *testing.T) {
|
||||
indexDigest := godigest.FromBytes(indexContent)
|
||||
So(indexDigest, ShouldNotBeNil)
|
||||
|
||||
_, _, err = imgStore.PutImageManifest(repoName, "1.0", ispec.MediaTypeImageIndex, indexContent)
|
||||
_, _, err = imgStore.PutImageManifest(repoName, "1.0", ispec.MediaTypeImageIndex, indexContent, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("sync index image", func() {
|
||||
@@ -1067,7 +1067,7 @@ func TestDestinationRegistry(t *testing.T) {
|
||||
So(manifestDigest, ShouldNotBeNil)
|
||||
|
||||
// Store the manifest in the temp image store
|
||||
_, _, err = tempImgStore.PutImageManifest(repoName, manifestDigest.String(), ispec.MediaTypeImageManifest, manifestContent)
|
||||
_, _, err = tempImgStore.PutImageManifest(repoName, manifestDigest.String(), ispec.MediaTypeImageManifest, manifestContent, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Add to index
|
||||
@@ -1085,7 +1085,7 @@ func TestDestinationRegistry(t *testing.T) {
|
||||
So(indexDigest, ShouldNotBeNil)
|
||||
|
||||
// Store the index manifest in the temp image store
|
||||
_, _, err = tempImgStore.PutImageManifest(repoName, indexDigest.String(), ispec.MediaTypeImageIndex, indexContent)
|
||||
_, _, err = tempImgStore.PutImageManifest(repoName, indexDigest.String(), ispec.MediaTypeImageIndex, indexContent, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Now remove one of the child manifest blobs to trigger the error
|
||||
@@ -1178,7 +1178,7 @@ func TestDestinationRegistry(t *testing.T) {
|
||||
digest = godigest.FromBytes(content)
|
||||
So(digest, ShouldNotBeNil)
|
||||
|
||||
_, _, err = imgStore.PutImageManifest(repoName, "2.0", ispec.MediaTypeImageManifest, content)
|
||||
_, _, err = imgStore.PutImageManifest(repoName, "2.0", ispec.MediaTypeImageManifest, content, nil)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("sync image", func() {
|
||||
|
||||
Reference in New Issue
Block a user