feat: add HWLAB runtime lane control CLI

This commit is contained in:
Codex
2026-06-08 06:48:50 +00:00
parent 8e189385f2
commit fb8c1aaebf
3 changed files with 745 additions and 118 deletions
+104
View File
@@ -0,0 +1,104 @@
export type HwlabRuntimeLane = "v02" | "v03";
export interface HwlabRuntimeLaneConfig {
readonly lane: HwlabRuntimeLane;
readonly minor: number;
}
export interface HwlabRuntimeLaneSpec {
readonly lane: HwlabRuntimeLane;
readonly minor: number;
readonly version: string;
readonly sourceBranch: string;
readonly workspace: string;
readonly cicdRepo: string;
readonly cicdRepoLock: string;
readonly app: string;
readonly pipeline: string;
readonly pipelineRunPrefix: string;
readonly serviceAccountName: string;
readonly controlPlaneFieldManager: string;
readonly gitUrl: string;
readonly gitReadUrl: string;
readonly gitWriteUrl: string;
readonly gitopsBranch: string;
readonly catalogPath: string;
readonly runtimePath: string;
readonly runtimeNamespace: string;
readonly runtimeRenderDir: string;
readonly tektonDir: string;
readonly argoApplicationFile: string;
readonly registryPrefix: string;
readonly baseImage: string;
readonly serviceIds: readonly string[];
readonly publicWebUrl: string;
readonly publicApiUrl: string;
}
export const HWLAB_RUNTIME_LANE_CONFIGS = [
{ lane: "v02", minor: 2 },
{ lane: "v03", minor: 3 },
] as const satisfies readonly HwlabRuntimeLaneConfig[];
const HWLAB_GIT_URL = "git@github.com:pikasTech/HWLAB.git";
const HWLAB_GIT_READ_URL = "http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git";
const HWLAB_GIT_WRITE_URL = "http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/HWLAB.git";
const HWLAB_REGISTRY_PREFIX = "127.0.0.1:5000/hwlab";
const HWLAB_BASE_IMAGE = "127.0.0.1:5000/hwlab/hwlab-node20-base:20-bookworm-slim";
const HWLAB_SERVICE_IDS = [
"hwlab-cloud-api",
"hwlab-cloud-web",
"hwlab-gateway",
"hwlab-edge-proxy",
"hwlab-agent-skills",
] as const;
function buildRuntimeLaneSpec(config: HwlabRuntimeLaneConfig): HwlabRuntimeLaneSpec {
const version = `v0.${config.minor}`;
const lane = config.lane;
return {
lane,
minor: config.minor,
version,
sourceBranch: version,
workspace: `/root/hwlab-${lane}`,
cicdRepo: `/root/hwlab-${lane}-cicd.git`,
cicdRepoLock: `/tmp/hwlab-${lane}-cicd-repo.lock`,
app: `hwlab-g14-${lane}`,
pipeline: `hwlab-${lane}-ci-image-publish`,
pipelineRunPrefix: `hwlab-${lane}-ci-poll`,
serviceAccountName: `hwlab-${lane}-tekton-runner`,
controlPlaneFieldManager: `unidesk-hwlab-${lane}-control-plane`,
gitUrl: HWLAB_GIT_URL,
gitReadUrl: HWLAB_GIT_READ_URL,
gitWriteUrl: HWLAB_GIT_WRITE_URL,
gitopsBranch: `${version}-gitops`,
catalogPath: `deploy/artifact-catalog.${lane}.json`,
runtimePath: `deploy/gitops/g14/runtime-${lane}`,
runtimeNamespace: `hwlab-${lane}`,
runtimeRenderDir: `runtime-${lane}`,
tektonDir: `tekton-${lane}`,
argoApplicationFile: `application-${lane}.yaml`,
registryPrefix: HWLAB_REGISTRY_PREFIX,
baseImage: HWLAB_BASE_IMAGE,
serviceIds: HWLAB_SERVICE_IDS,
publicWebUrl: `http://74.48.78.17:${19466 + config.minor * 100}`,
publicApiUrl: `http://74.48.78.17:${19467 + config.minor * 100}`,
};
}
const RUNTIME_LANE_SPECS = Object.fromEntries(
HWLAB_RUNTIME_LANE_CONFIGS.map((config) => [config.lane, buildRuntimeLaneSpec(config)]),
) as Record<HwlabRuntimeLane, HwlabRuntimeLaneSpec>;
export function isHwlabRuntimeLane(value: string): value is HwlabRuntimeLane {
return Object.prototype.hasOwnProperty.call(RUNTIME_LANE_SPECS, value);
}
export function hwlabRuntimeLaneSpec(lane: HwlabRuntimeLane): HwlabRuntimeLaneSpec {
return RUNTIME_LANE_SPECS[lane];
}
export function hwlabRuntimeLaneIds(): HwlabRuntimeLane[] {
return HWLAB_RUNTIME_LANE_CONFIGS.map((config) => config.lane);
}
+605 -115
View File
File diff suppressed because it is too large Load Diff