fix(sentinel): add YAML shortest-path validation
This commit is contained in:
@@ -128,6 +128,48 @@ export function runSentinelMaintenance(state: SentinelCicdState, options: Extrac
|
||||
|
||||
export function runSentinelValidate(state: SentinelCicdState, options: Extract<WebProbeSentinelOptions, { kind: "validate" }>): RenderedCliResult {
|
||||
const command = "web-probe sentinel validate";
|
||||
if (options.localOnly) {
|
||||
const cronJob = state.manifests.find((item) => item.kind === "CronJob") ?? null;
|
||||
const scenarioId = stringAt(state.cicd, "targetValidation.scenarioId");
|
||||
const scenarioRows = Array.isArray(state.scenarios)
|
||||
? state.scenarios
|
||||
: Array.isArray(record(state.scenarios).scenarios)
|
||||
? record(state.scenarios).scenarios as unknown[]
|
||||
: [];
|
||||
const scenario = scenarioRows.map(record).find((item) => item.id === scenarioId) ?? null;
|
||||
const cadence = scenario === null ? null : scenario.cadence ?? null;
|
||||
const renderedCron = cronJob === null ? null : record(cronJob.spec).schedule ?? null;
|
||||
const result = {
|
||||
ok: state.configReady && state.sourceHead.ok && cadence !== null && renderedCron !== null,
|
||||
command,
|
||||
mode: "local",
|
||||
mutation: false,
|
||||
node: state.spec.nodeId,
|
||||
lane: state.spec.lane,
|
||||
sentinelId: state.sentinelId,
|
||||
configRef: state.configRefs.scenarios,
|
||||
scenarioId,
|
||||
cadence,
|
||||
renderedCron,
|
||||
sourceCommit: state.sourceHead.commit,
|
||||
manifestSha256: state.manifestSha256,
|
||||
valuesRedacted: true,
|
||||
};
|
||||
return rendered(result.ok, command, [
|
||||
command,
|
||||
`status: ${result.ok ? "ok" : "blocked"}`,
|
||||
`node: ${result.node}`,
|
||||
`lane: ${result.lane}`,
|
||||
`sentinelId: ${result.sentinelId}`,
|
||||
`configRef: ${result.configRef}`,
|
||||
`scenarioId: ${result.scenarioId}`,
|
||||
`cadence: ${result.cadence ?? "-"}`,
|
||||
`renderedCron: ${result.renderedCron ?? "-"}`,
|
||||
`sourceCommit: ${result.sourceCommit ?? "-"}`,
|
||||
`manifestSha256: ${result.manifestSha256}`,
|
||||
"mutation: false",
|
||||
].join("\n"), result);
|
||||
}
|
||||
const startedAt = Date.now();
|
||||
const initialHealth = callSentinelService(state, "GET", "/api/health", null, options.timeoutSeconds);
|
||||
let quickVerify: Record<string, unknown> | null = null;
|
||||
|
||||
Reference in New Issue
Block a user