about summary refs log tree commit diff
path: root/tools/nixery
diff options
context:
space:
mode:
authorJerome Petazzoni <jerome.petazzoni@gmail.com>2021-04-13T14·26+0200
committerVincent Ambo <mail@tazj.in>2021-04-27T13·39+0200
commitf172107ef1b2568bd3a1b1eafa4b9e2546e14c1d (patch)
tree3742e727729a1e1794280328b2f4c23863c01b71 /tools/nixery
parent954953d8bad1978b529df146d8ea50d91d4e257a (diff)
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.
Diffstat (limited to 'tools/nixery')
-rw-r--r--tools/nixery/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/nixery/main.go b/tools/nixery/main.go
index d94d51b4681e..6af4636e51a0 100644
--- a/tools/nixery/main.go
+++ b/tools/nixery/main.go
@@ -195,6 +195,16 @@ func (h *registryHandler) serveManifestTag(w http.ResponseWriter, r *http.Reques
 // serveBlob serves a blob from storage by digest
 func (h *registryHandler) serveBlob(w http.ResponseWriter, r *http.Request, blobType, digest string) {
 	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)
 	if err != nil {
 		log.WithError(err).WithFields(log.Fields{