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 14, 2024
1 parent 6a19e9b commit 8e77033
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [#475](https://github.com/XenitAB/spegel/pull/475) Move resolving ref to digest to manifest handler.

### Deprecated

### Removed
Expand Down
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 8e77033

Please sign in to comment.