fix: validate maintenance profiles and canonical local auth origins
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user