Generalize runtime lane git mirror refs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user