fix: add yaml runtime image build for d518

This commit is contained in:
Codex
2026-06-27 14:36:10 +00:00
parent c03d77f347
commit 8c3770d15e
5 changed files with 199 additions and 21 deletions
+42
View File
@@ -254,6 +254,17 @@ export interface HwlabRuntimeImageRewriteSpec {
readonly target: string;
}
export interface HwlabRuntimeImageBuildSpec {
readonly id: string;
readonly kind: "moonbridge";
readonly target: string;
readonly sourceRepo: string;
readonly sourceRef: string;
readonly builderImage: string;
readonly goProxy: string;
readonly dockerNetworkMode: "default" | "host";
}
export interface HwlabRuntimePublicExposureFrpcProxySpec {
readonly name: string;
readonly localIP: string;
@@ -346,6 +357,7 @@ export interface HwlabRuntimeLaneSpec {
readonly publicExposure: HwlabRuntimePublicExposureSpec | null;
readonly observability: HwlabRuntimeObservabilitySpec;
readonly runtimeImageRewrites: readonly HwlabRuntimeImageRewriteSpec[];
readonly runtimeImageBuilds: readonly HwlabRuntimeImageBuildSpec[];
readonly networkProfileId: string;
readonly downloadProfileId: string;
readonly networkProfile: HwlabNetworkProfileSpec;
@@ -395,6 +407,7 @@ interface HwlabLaneConfig {
readonly publicExposure: HwlabRuntimePublicExposureSpec | null;
readonly observability: HwlabRuntimeObservabilitySpec;
readonly runtimeImageRewrites: readonly HwlabRuntimeImageRewriteSpec[];
readonly runtimeImageBuilds: readonly HwlabRuntimeImageBuildSpec[];
}
interface HwlabNodeLaneConfig {
@@ -421,6 +434,12 @@ function stringField(obj: Record<string, unknown>, key: string, path: string): s
return value;
}
function enumStringField<T extends string>(obj: Record<string, unknown>, key: string, path: string, allowed: readonly T[]): T {
const value = stringField(obj, key, path);
if (!allowed.includes(value as T)) throw new Error(`${path}.${key} must be one of ${allowed.join(", ")}`);
return value as T;
}
function numberField(obj: Record<string, unknown>, key: string, path: string): number {
const value = obj[key];
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) throw new Error(`${path}.${key} must be a positive integer`);
@@ -630,6 +649,7 @@ function laneConfig(id: HwlabRuntimeLane, raw: Record<string, unknown>): HwlabLa
publicExposure: publicExposureConfig(raw.publicExposure, `lanes.${id}.publicExposure`),
observability: observabilityConfig(raw.observability, `lanes.${id}.observability`),
runtimeImageRewrites: runtimeImageRewritesConfig(raw.runtimeImageRewrites, `lanes.${id}.runtimeImageRewrites`),
runtimeImageBuilds: runtimeImageBuildsConfig(raw.runtimeImageBuilds, `lanes.${id}.runtimeImageBuilds`),
};
}
@@ -1149,6 +1169,27 @@ function runtimeImageRewritesConfig(value: unknown, path: string): HwlabRuntimeI
});
}
function runtimeImageBuildsConfig(value: unknown, path: string): HwlabRuntimeImageBuildSpec[] {
if (value === undefined) return [];
if (!Array.isArray(value)) throw new Error(`${path} must be an array`);
return value.map((item, index) => {
const itemPath = `${path}[${index}]`;
const raw = asRecord(item, itemPath);
const kind = stringField(raw, "kind", itemPath);
if (kind !== "moonbridge") throw new Error(`${itemPath}.kind must be moonbridge`);
return {
id: stringField(raw, "id", itemPath),
kind,
target: stringField(raw, "target", itemPath),
sourceRepo: stringField(raw, "sourceRepo", itemPath),
sourceRef: stringField(raw, "sourceRef", itemPath),
builderImage: stringField(raw, "builderImage", itemPath),
goProxy: stringField(raw, "goProxy", itemPath),
dockerNetworkMode: enumStringField(raw, "dockerNetworkMode", itemPath, ["default", "host"]),
};
});
}
function readHwlabNodeLaneConfig(): HwlabNodeLaneConfig {
const path = rootPath(HWLAB_NODE_LANE_CONFIG_PATH);
const raw = readFileSync(path, "utf8");
@@ -1273,6 +1314,7 @@ function buildRuntimeLaneSpec(config: HwlabLaneConfig): HwlabRuntimeLaneSpec {
publicExposure: config.publicExposure,
observability: config.observability,
runtimeImageRewrites: config.runtimeImageRewrites,
runtimeImageBuilds: config.runtimeImageBuilds,
networkProfileId: networkProfile.id,
downloadProfileId: downloadProfile.id,
networkProfile,