1
0
Fork 0
mirror of https://github.com/imjasonh/kontain.me synced 2026-07-18 23:03:06 +00:00

Support pull by digest, for images that have previously been built

This commit is contained in:
Jason Hall 2019-05-24 15:54:38 +02:00
parent e9b607a2f7
commit 7f6572d0a2
4 changed files with 53 additions and 33 deletions

View file

@ -42,10 +42,15 @@ func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// API Version check.
w.Header().Set("Docker-Distribution-API-Version", "registry/2.0")
return
case strings.Contains(path, "/blobs/"),
strings.Contains(path, "/manifests/sha256:"):
// Extract requested blob digest and redirect to serve it from GCS.
// If it doesn't exist, this will return 404.
parts := strings.Split(r.URL.Path, "/")
digest := parts[len(parts)-1]
serve.Blob(w, r, digest)
case strings.Contains(path, "/manifests/"):
s.serveRandomManifest(w, r)
case strings.Contains(path, "/blobs/"):
serve.Blob(w, r)
default:
serve.Error(w, serve.ErrNotFound)
}
@ -77,5 +82,5 @@ func (s *server) serveRandomManifest(w http.ResponseWriter, r *http.Request) {
serve.Error(w, err)
return
}
serve.Manifest(w, img)
serve.Manifest(w, r, img)
}