mirror of
https://github.com/imjasonh/kontain.me
synced 2026-07-08 00:55:14 +00:00
support mirroring tags and digests
This commit is contained in:
parent
1f0dd6c72e
commit
0b1b4615dd
1 changed files with 7 additions and 1 deletions
|
|
@ -77,13 +77,19 @@ func (s *server) serveMirrorManifest(w http.ResponseWriter, r *http.Request) {
|
|||
parts := strings.Split(path, "/")
|
||||
|
||||
refstr := strings.Join(parts[:len(parts)-2], "/")
|
||||
tagOrDigest := parts[len(parts)-1]
|
||||
if strings.HasPrefix(tagOrDigest, "sha256:") {
|
||||
refstr += "@" + tagOrDigest
|
||||
} else {
|
||||
refstr += ":" + tagOrDigest
|
||||
}
|
||||
for strings.HasPrefix(refstr, "mirror.kontain.me/") {
|
||||
refstr = strings.TrimPrefix(refstr, "mirror.kontain.me/")
|
||||
}
|
||||
|
||||
ref, err := name.ParseReference(refstr)
|
||||
if err != nil {
|
||||
s.error.Printf("ERROR (ParseReference): %v", err)
|
||||
s.error.Printf("ERROR (ParseReference(%q)): %v", refstr, err)
|
||||
serve.Error(w, err)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue