fix: validate maintenance profiles and canonical local auth origins

This commit is contained in:
Codex
2026-10-06 16:09:39 +02:00
parent d79e261e09
commit 2aac228cdc
10 changed files with 106 additions and 11 deletions
+2 -2
View File
@@ -28,13 +28,13 @@ func CheckCompose(ctx context.Context, runner Runner, installation config.Instal
}
args = append(args, "-f", path)
}
args = append(args, "config", "--format", "json")
args = append(args, "--profile", "catalog-maintenance", "--profile", "workspace-maintenance", "config", "--format", "json")
return checkResolvedCompose(ctx, runner, args, m, platform)
}
// CheckInstalledCompose includes generated projections and any durable image override.
func CheckInstalledCompose(ctx context.Context, runner Runner, installation config.Installation, m Manifest, platform string) Report {
return checkResolvedCompose(ctx, runner, installation.ComposeArgs("config", "--format", "json"), m, platform)
return checkResolvedCompose(ctx, runner, installation.ComposeArgs("--profile", "catalog-maintenance", "--profile", "workspace-maintenance", "config", "--format", "json"), m, platform)
}
func checkResolvedCompose(ctx context.Context, runner Runner, args []string, m Manifest, platform string) Report {
+23 -1
View File
@@ -29,7 +29,16 @@ func (f *fakeDocker) Run(_ context.Context, args []string, _ io.Reader) (compose
case "compose":
if args[len(args)-1] == "json" {
if f.effective != "" {
return compose.Result{Stdout: f.effective}, nil
var resolved map[string]map[string]any
_ = json.Unmarshal([]byte(f.effective), &resolved)
line := strings.Join(args, " ")
for service, profile := range map[string]string{"catalog-migrate": "catalog-maintenance", "workspace-maintenance": "workspace-maintenance"} {
if !strings.Contains(line, "--profile "+profile) {
delete(resolved["services"], service)
}
}
data, _ := json.Marshal(resolved)
return compose.Result{Stdout: string(data)}, nil
}
return compose.Result{Stdout: `{"services":{"core":{"image":"example/core:latest"}}}`}, nil
}
@@ -40,6 +49,19 @@ func (f *fakeDocker) Run(_ context.Context, args []string, _ io.Reader) (compose
return compose.Result{}, errors.New("unexpected command")
}
func TestComposeIncludesInactiveMaintenanceProfilesBeforeInstallation(t *testing.T) {
m := Manifest{Images: map[string]map[string]string{}, Compose: []string{"compose.yaml"}}
services := map[string]map[string]string{}
for service, role := range map[string]string{"core": "core", "frontend": "frontend", "catalog-db": "catalog", "catalog-migrate": "core", "workspace-maintenance": "core", "qdrant": "qdrant", "embedding": "embedding", "embedding-model-init": "embedding"} {
m.Images[role] = map[string]string{"linux/amd64": "docker.io/example/" + role + "@sha256:" + strings.Repeat("a", 64)}
services[service] = map[string]string{"image": m.Images[role]["linux/amd64"]}
}
data, _ := json.Marshal(map[string]any{"services": services})
if r := CheckCompose(context.Background(), &fakeDocker{effective: string(data)}, config.Installation{}, m, "/release/manifest.json", "linux/amd64"); !r.OK {
t.Fatalf("maintenance profiles missing: %+v", r)
}
}
func TestComposeRejectsIncompleteMutableServiceSet(t *testing.T) {
r := CheckCompose(context.Background(), &fakeDocker{}, config.Installation{ProjectDirectory: "/private", EnvFile: "/private/operator.env"}, Manifest{Compose: []string{"compose.yaml"}}, "/release/manifest.json", "linux/amd64")
if r.OK {