mirror of
https://code.tvl.fyi/depot.git:/tools/nixery.git
synced 2025-03-14 21:51:52 +00:00
feat(storage): Add generic support for content-types
When serving a manifest, it is important to set the content-type correctly (otherwise pulling an image is likely to give a cryptic error message, "Error response from daemon: missing signature key"). This makes sure that we set the content-type properly for both manifests and layers.
This commit is contained in:
parent
d8ae0bb2f6
commit
7db252f36a
10
main.go
10
main.go
|
@ -195,6 +195,16 @@ func (h *registryHandler) serveManifestTag(w http.ResponseWriter, r *http.Reques
|
||||||
// serveBlob serves a blob from storage by digest
|
// serveBlob serves a blob from storage by digest
|
||||||
func (h *registryHandler) serveBlob(w http.ResponseWriter, r *http.Request, blobType, digest string) {
|
func (h *registryHandler) serveBlob(w http.ResponseWriter, r *http.Request, blobType, digest string) {
|
||||||
storage := h.state.Storage
|
storage := h.state.Storage
|
||||||
|
switch blobType {
|
||||||
|
case "manifests":
|
||||||
|
// It is necessary to set the correct content-type when serving manifests.
|
||||||
|
// Otherwise, you may get the following mysterious error message when pulling:
|
||||||
|
// "Error response from daemon: missing signature key"
|
||||||
|
w.Header().Add("Content-Type", mf.ManifestType)
|
||||||
|
case "blobs":
|
||||||
|
// It is not strictly necessary to set this content-type, but since we're here...
|
||||||
|
w.Header().Add("Content-Type", mf.LayerType)
|
||||||
|
}
|
||||||
err := storage.Serve(digest, r, w)
|
err := storage.Serve(digest, r, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).WithFields(log.Fields{
|
log.WithError(err).WithFields(log.Fields{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user