fix(offsite): 服务器或白名单按摘要钉住的 felis/ 与 mirror/ 版本也进异地副本,恢复只按摘要推回不动安装器的 tag

This commit is contained in:
Lemon-miaow committed 2026-09-25 05:00:02 +08:00
1 parent 8fb3d298ae
commit 2779d8f5cf
8 files changed
+158 -20

No files matched your search

+3 -3
View File
@@ -172,7 +172,7 @@ func (p *Pruner) log() *slog.Logger {
func Plan(indexes map[string]*registrygate.Index, refs []string, host string, now time.Time, grace time.Duration, keepTagged int) []Target {
keep := map[Target]bool{}
for _, ref := range refs {
repo, tag, digest, ok := parseRef(ref, host)
repo, tag, digest, ok := ParseRef(ref, host)
if !ok {
continue
}
@@ -255,9 +255,9 @@ func reserved(repo string) bool {
return false
}
// parseRef splits host/repo[:tag][@digest] for refs under host. A ref with
// ParseRef splits host/repo[:tag][@digest] for refs under host. A ref with
// neither tag nor digest means :latest, as it does for every image client.
func parseRef(ref, host string) (repo, tag, digest string, ok bool) {
func ParseRef(ref, host string) (repo, tag, digest string, ok bool) {
rest, ok := strings.CutPrefix(strings.TrimSpace(ref), host+"/")
if !ok || rest == "" {
return "", "", "", false
+2 -2
View File
@@ -124,9 +124,9 @@ func TestParseRef(t *testing.T) {
{"other:5000/felis/paper:demo", "", "", "", false},
{host + "/", "", "", "", false},
} {
repo, tag, digest, ok := parseRef(c.ref, host)
repo, tag, digest, ok := ParseRef(c.ref, host)
if repo != c.repo || tag != c.tag || digest != c.digest || ok != c.ok {
t.Errorf("parseRef(%q) = %q %q %q %v, want %q %q %q %v", c.ref, repo, tag, digest, ok, c.repo, c.tag, c.digest, c.ok)
t.Errorf("ParseRef(%q) = %q %q %q %v, want %q %q %q %v", c.ref, repo, tag, digest, ok, c.repo, c.tag, c.digest, c.ok)
}
}
}