Generalize runtime lane git mirror refs

This commit is contained in:
Codex Agent
2026-06-08 14:46:20 +08:00
parent 6c5166d816
commit 1657c84697
3 changed files with 162 additions and 78 deletions
+25
View File
@@ -34,6 +34,14 @@ export type RuntimeLaneConfig = {
sourceRepo?: string;
};
export type RuntimeLaneMirrorSpec = {
lane: string;
sourceBranch: string;
gitopsBranch: string;
artifactCatalog: string;
runtimePath: string;
};
export type DeployConfig = {
lanes?: Record<string, RuntimeLaneConfig | undefined>;
};
@@ -111,6 +119,23 @@ export function applyRuntimeLaneDeployConfig(args: GitOpsRenderArgs, deploy: Dep
return result;
}
export function runtimeLaneMirrorSpecs(deploy: DeployConfig): RuntimeLaneMirrorSpec[] {
return Object.entries(deploy.lanes ?? {})
.filter(([lane, config]) => isRuntimeLane(lane) && isObject(config))
.sort(([left], [right]) => runtimeLaneMinor(left) - runtimeLaneMinor(right))
.map(([lane, config]) => {
const laneConfig = config as RuntimeLaneConfig;
const versionName = versionNameForRuntimeLane(lane);
return {
lane,
sourceBranch: laneConfig.sourceBranch ?? versionName,
gitopsBranch: laneConfig.gitopsBranch ?? `${versionName}-gitops`,
artifactCatalog: laneConfig.artifactCatalog ?? `deploy/artifact-catalog.${lane}.json`,
runtimePath: `deploy/gitops/g14/${runtimePathForRuntimeLane(lane)}`,
};
});
}
function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}