feat: support explicit source bundles through the common installer

This commit is contained in:
Codex
2026-10-06 18:31:23 +02:00
parent 785d96ea50
commit 5c05778614
11 changed files with 353 additions and 5 deletions
@@ -82,6 +82,7 @@ type dockerFixture struct {
calls [][]string
fail string
wrongImage bool
source bool
}
func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (compose.Result, error) {
@@ -133,6 +134,9 @@ func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (
continue
}
services[service] = map[string]string{"image": "docker.io/example/" + role + "@sha256:" + strings.Repeat("a", 64)}
if r.source && (role == "core" || role == "frontend") {
services[service] = map[string]string{"image": "sha256:" + strings.Repeat("a", 64)}
}
}
if r.wrongImage {
services["core"] = map[string]string{"image": "unverified:latest"}
@@ -149,6 +153,36 @@ func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (
return compose.Result{Stdout: `{"ok":true}`}, nil
}
func TestExplicitSourceApplySharesReadinessAndPullsOnlyUpstream(t *testing.T) {
path, p := fixture(t)
p.Release.Distribution = "source"
for _, role := range []string{"core", "frontend"} {
p.Release.Images[role][p.Platform] = "sha256:" + strings.Repeat("a", 64)
}
data, _ := json.Marshal(p.Release)
if err := os.WriteFile(p.ManifestPath, data, 0o600); err != nil {
t.Fatal(err)
}
_ = os.Remove(path)
_ = os.Remove(path + ".key")
if err := preflight.WritePlan(path, &p); err != nil {
t.Fatal(err)
}
r := &dockerFixture{source: true}
result, err := Run(context.Background(), Request{PlanPath: path, InstallationPath: p.Installation.Path}, r, func(context.Context, preflight.Plan) error { return nil })
if err != nil || !result.WorkspaceReady || result.Distribution != "source" {
t.Fatalf("source apply: %+v %v", result, err)
}
for _, call := range flatten(r.calls) {
if strings.Contains(call, " pull ") && !strings.Contains(call, "pull --policy always catalog-db qdrant embedding embedding-model-init") {
t.Fatal("source application images pulled")
}
if strings.Contains(call, " build ") {
t.Fatal("apply implicitly built source")
}
}
}
func TestApplyRefusesUnreleasedEffectiveImageBeforePull(t *testing.T) {
path, p := fixture(t)
r := &dockerFixture{wrongImage: true}