Restore: автозамена minio/minio и minio/mc на pgsty/silo и pgsty/mc
Образы minio удалены с Docker Hub, Stoat перешёл на silo (drop-in). Замена идёт через compose.restore.yml, исходные compose-файлы не трогаются. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7e29fb11eb
commit
09661bf22c
2 files changed
+44
-1
No files matched your search
@@ -134,6 +134,22 @@ func (r *restorer) pullFallback(c manifest.Category, compose func(...string) err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// removedImages — образы, исчезнувшие из реестров, и их drop-in замены.
|
||||||
|
// minio/* убраны с Docker Hub; Stoat перешёл на форк silo (stoatchat/self-hosted#306),
|
||||||
|
// который сам мигрирует каталог данных minio.
|
||||||
|
var removedImages = map[string]string{
|
||||||
|
"minio/minio": "docker.io/pgsty/silo",
|
||||||
|
"minio/mc": "docker.io/pgsty/mc",
|
||||||
|
}
|
||||||
|
|
||||||
|
func replacedImage(ref string) (string, bool) {
|
||||||
|
repo, _, _ := strings.Cut(ref, "@")
|
||||||
|
repo, _, _ = strings.Cut(repo, ":")
|
||||||
|
repo = strings.TrimPrefix(repo, "docker.io/")
|
||||||
|
repl, ok := removedImages[repo]
|
||||||
|
return repl, ok
|
||||||
|
}
|
||||||
|
|
||||||
func (r *restorer) writePinFileSkip(c manifest.Category, skip map[string]bool) (string, error) {
|
func (r *restorer) writePinFileSkip(c manifest.Category, skip map[string]bool) (string, error) {
|
||||||
var services []string
|
var services []string
|
||||||
for name := range c.Compose.Images {
|
for name := range c.Compose.Images {
|
||||||
@@ -149,7 +165,14 @@ func (r *restorer) writePinFileSkip(c manifest.Category, skip map[string]bool) (
|
|||||||
if img.Built || img.Digest == "" || skip[svc] {
|
if img.Built || img.Digest == "" || skip[svc] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&b, " %q:\n image: %q\n", svc, img.Digest)
|
ref := img.Digest
|
||||||
|
if repl, ok := replacedImage(ref); ok {
|
||||||
|
if skip == nil {
|
||||||
|
r.warn("%s: образ %s удалён из реестра, сервис %s переведён на %s", c.Name, ref, svc, repl)
|
||||||
|
}
|
||||||
|
ref = repl
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, " %q:\n image: %q\n", svc, ref)
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
p := filepath.Join(c.Compose.Dir, pinFile)
|
p := filepath.Join(c.Compose.Dir, pinFile)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package restore
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestReplacedImage(t *testing.T) {
|
||||||
|
cases := map[string]string{
|
||||||
|
"minio/minio@sha256:abc": "docker.io/pgsty/silo",
|
||||||
|
"docker.io/minio/mc:latest": "docker.io/pgsty/mc",
|
||||||
|
"minio/minio": "docker.io/pgsty/silo",
|
||||||
|
}
|
||||||
|
for in, want := range cases {
|
||||||
|
got, ok := replacedImage(in)
|
||||||
|
if !ok || got != want {
|
||||||
|
t.Errorf("%s: got %q,%v want %q", in, got, ok, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := replacedImage("mongo@sha256:abc"); ok {
|
||||||
|
t.Error("mongo не должен заменяться")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user