Merge pull request #1314 from pikasTech/fix/issue-1312-env-reuse
fix: stabilize D601 env reuse planning
This commit is contained in:
@@ -1572,12 +1572,22 @@ function prepareSourceScript() {
|
||||
"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 ids = (doc) => (doc.services || []).map((service) => service.serviceId).filter(Boolean);",
|
||||
"const selected = (selectedServices || \"\").split(\",\").map((item) => item.trim()).filter(Boolean);",
|
||||
"const uniqueSorted = (items) => [...new Set(items)].sort();",
|
||||
"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);",
|
||||
"const actual = ids(gitops);",
|
||||
"const expectedSet = uniqueSorted(expected);",
|
||||
"const actualSet = uniqueSorted(actual);",
|
||||
"const sameServices = expectedSet.length === actualSet.length && expectedSet.every((item, index) => item === actualSet[index]);",
|
||||
"if (!sameServices) {",
|
||||
" const missing = expectedSet.filter((item) => !actualSet.includes(item));",
|
||||
" const extra = actualSet.filter((item) => !expectedSet.includes(item));",
|
||||
" console.error(JSON.stringify({ event: \"gitops-artifact-catalog\", phase: \"prepare-source\", status: \"ignored-stale\", reason: \"service-ids-mismatch\", expected, actual, missing, extra }));",
|
||||
" process.exit(42);",
|
||||
"}",
|
||||
"NODE",
|
||||
" then",
|
||||
" cp /tmp/hwlab-gitops-artifact-catalog.json \"$catalog_path\"",
|
||||
|
||||
@@ -666,10 +666,20 @@ export async function hashGitPaths(repoRoot, targetRef, paths, options = {}) {
|
||||
async function hashEnvReuseInputs(repoRoot, targetRef, paths, recipe, options = {}) {
|
||||
return stableHash({
|
||||
gitPaths: await hashGitPaths(repoRoot, targetRef, paths, options),
|
||||
envRecipe: recipe
|
||||
envRecipe: envReuseIdentityRecipe(recipe)
|
||||
});
|
||||
}
|
||||
|
||||
function envReuseIdentityRecipe(recipe) {
|
||||
const identity = JSON.parse(JSON.stringify(recipe ?? {}));
|
||||
if (identity.downloadStack && typeof identity.downloadStack === "object") {
|
||||
delete identity.downloadStack.httpProxy;
|
||||
delete identity.downloadStack.httpsProxy;
|
||||
delete identity.downloadStack.noProxy;
|
||||
}
|
||||
return identity;
|
||||
}
|
||||
|
||||
export async function lastCommitForPaths(repoRoot, targetRef, paths) {
|
||||
const normalizedPaths = uniqueSorted(paths.map(normalizeRepoPath).filter(Boolean));
|
||||
if (normalizedPaths.length === 0) return null;
|
||||
|
||||
Reference in New Issue
Block a user