mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-21 00:38:14 +08:00
24 lines
848 B
TypeScript
24 lines
848 B
TypeScript
import type { ExecutionSpec } from './execution';
|
|
import { cloneExecutionSpec } from './executionSpec';
|
|
import type { RunDispatchCandidate } from './runDispatchCandidate';
|
|
|
|
/** Normalizes a trusted plan and binds it to one persisted candidate identity. */
|
|
export function executionSpecForRunDispatchCandidate(
|
|
candidate: RunDispatchCandidate,
|
|
value: ExecutionSpec,
|
|
): ExecutionSpec {
|
|
const executionSpec = cloneExecutionSpec(value);
|
|
if (
|
|
executionSpec.runId !== candidate.runId ||
|
|
executionSpec.attemptId !== candidate.attemptId ||
|
|
executionSpec.projectId !== candidate.projectId ||
|
|
executionSpec.taskId !== candidate.taskId ||
|
|
executionSpec.taskRevision !== candidate.taskRevision
|
|
) {
|
|
throw new TypeError(
|
|
'ExecutionSpec identity does not match its dispatch candidate',
|
|
);
|
|
}
|
|
return executionSpec;
|
|
}
|