Skip to content

Commit

Permalink
Remove containerd info call when handling manifest request
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba committed Feb 22, 2023
1 parent e302350 commit 16dbf34
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/containerd/containerd"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/reference"
"github.com/gin-gonic/gin"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -229,13 +230,7 @@ func (r *RegistryHandler) handleManifest(c *gin.Context, ref reference.Spec) {
}
dgst = image.Target.Digest
}
info, err := r.containerdClient.ContentStore().Info(c, dgst)
if err != nil {
//nolint:errcheck // ignore
c.AbortWithError(http.StatusNotFound, err)
return
}
b, err := content.ReadBlob(c, r.containerdClient.ContentStore(), ocispec.Descriptor{Digest: info.Digest})
b, err := content.ReadBlob(c, r.containerdClient.ContentStore(), ocispec.Descriptor{Digest: dgst})
if err != nil {
//nolint:errcheck // ignore
c.AbortWithError(http.StatusNotFound, err)
Expand All @@ -248,8 +243,8 @@ func (r *RegistryHandler) handleManifest(c *gin.Context, ref reference.Spec) {
return
}
c.Header("Content-Type", mediaType)
c.Header("Content-Length", strconv.FormatInt(info.Size, 10))
c.Header("Docker-Content-Digest", info.Digest.String())
c.Header("Content-Length", strconv.FormatInt(int64(len(b)), 10))
c.Header("Docker-Content-Digest", dgst.String())
if c.Request.Method == "HEAD" {
c.Status(http.StatusOK)
return
Expand Down

0 comments on commit 16dbf34

Please sign in to comment.