Skip to content

Commit

Permalink
Move resolving ref to digest to manifest handler
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba committed May 13, 2024
1 parent 6b84339 commit e82e833
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,9 @@ func (r *Registry) registryHandler(rw mux.ResponseWriter, req *http.Request) str
}

// Serve registry endpoints.
if dgst == "" {
dgst, err = r.ociClient.Resolve(req.Context(), ref)
if err != nil {
rw.WriteError(http.StatusNotFound, err)
return ""
}
}

switch refType {
case referenceTypeManifest:
r.handleManifest(rw, req, dgst)
r.handleManifest(rw, req, ref, dgst)
return "manifest"
case referenceTypeBlob:
r.handleBlob(rw, req, dgst)
Expand Down Expand Up @@ -297,7 +289,15 @@ func (r *Registry) handleMirror(rw mux.ResponseWriter, req *http.Request, key st
}
}

func (r *Registry) handleManifest(rw mux.ResponseWriter, req *http.Request, dgst digest.Digest) {
func (r *Registry) handleManifest(rw mux.ResponseWriter, req *http.Request, ref string, dgst digest.Digest) {
if dgst == "" {
var err error
dgst, err = r.ociClient.Resolve(req.Context(), ref)
if err != nil {
rw.WriteError(http.StatusNotFound, err)
return
}
}
b, mediaType, err := r.ociClient.GetManifest(req.Context(), dgst)
if err != nil {
rw.WriteError(http.StatusNotFound, err)
Expand Down

0 comments on commit e82e833

Please sign in to comment.