refactor: keep deploy yaml parsing in config layer

This commit is contained in:
Codex Agent
2026-06-08 12:42:30 +08:00
parent e17d7f92b2
commit 5a92233bd9
+12 -1
View File
@@ -1492,7 +1492,18 @@ function prepareSourceScript() {
" git_timed catalog-fetch 90 git fetch --depth 1 gitops-catalog \"$(params.gitops-branch)\" >/dev/null || true",
" if git cat-file -e FETCH_HEAD:\"$catalog_path\" 2>/dev/null; then",
" git show FETCH_HEAD:\"$catalog_path\" > /tmp/hwlab-gitops-artifact-catalog.json",
" if node --input-type=module -e 'import fs from \"node:fs\"; import { readStructuredFile } from \"./scripts/src/structured-config.mjs\"; const ids=(doc)=>(doc.services||[]).map((s)=>s.serviceId); const selected=(process.argv[3]||\"\").split(\",\").filter(Boolean); const gitops=JSON.parse(fs.readFileSync(process.argv[1],\"utf8\")); const deploy=await readStructuredFile(process.cwd(),process.argv[2]); const expected=selected.length ? selected : ids(deploy); if (JSON.stringify(ids(gitops)) !== JSON.stringify(expected)) process.exit(42);' /tmp/hwlab-gitops-artifact-catalog.json deploy/deploy.yaml \"$(params.services)\"; then",
" if node --input-type=module - /tmp/hwlab-gitops-artifact-catalog.json deploy/deploy.yaml \"$(params.services)\" <<'NODE'",
"import fs from \"node:fs\";",
"import { readStructuredFile } from \"./scripts/src/structured-config.mjs\";",
"const [catalogPath, deployPath, selectedServices] = process.argv.slice(2);",
"const ids = (doc) => (doc.services || []).map((service) => service.serviceId);",
"const selected = (selectedServices || \"\").split(\",\").filter(Boolean);",
"const gitops = JSON.parse(fs.readFileSync(catalogPath, \"utf8\"));",
"const deploy = await readStructuredFile(process.cwd(), deployPath);",
"const expected = selected.length ? selected : ids(deploy);",
"if (JSON.stringify(ids(gitops)) !== JSON.stringify(expected)) process.exit(42);",
"NODE",
" then",
" cp /tmp/hwlab-gitops-artifact-catalog.json \"$catalog_path\"",
" echo '{\"event\":\"gitops-artifact-catalog\",\"phase\":\"prepare-source\",\"status\":\"loaded\",\"branch\":\"'\"$(params.gitops-branch)\"'\"}'",
" else",