fix: share native cicd script loader

This commit is contained in:
Codex
2026-07-03 15:25:45 +00:00
parent 244f10d154
commit e20739a0f2
2 changed files with 4 additions and 8 deletions
+2 -6
View File
@@ -35,7 +35,7 @@ export function readNativeObjectBundle(registry: BranchFollowerRegistry, followe
"tmpdir=$(mktemp -d)", "tmpdir=$(mktemp -d)",
"cleanup() { rm -rf \"$tmpdir\"; }", "cleanup() { rm -rf \"$tmpdir\"; }",
"trap cleanup EXIT INT TERM", "trap cleanup EXIT INT TERM",
nativeBundleScriptLoadShell(), nativeCicdScriptLoadShell(NATIVE_BUNDLE_SCRIPT_NAMES),
`REPO_PATH=${shQuote(source.repoPath)}`, `REPO_PATH=${shQuote(source.repoPath)}`,
`SOURCE_BRANCH=${shQuote(follower.source.branch)}`, `SOURCE_BRANCH=${shQuote(follower.source.branch)}`,
`REPOSITORY=${shQuote(follower.source.repository)}`, `REPOSITORY=${shQuote(follower.source.repository)}`,
@@ -80,11 +80,7 @@ export function readNativeObjectBundle(registry: BranchFollowerRegistry, followe
}; };
} }
function nativeBundleScriptLoadShell(): string { export function nativeCicdScriptLoadShell(names: readonly string[]): string {
return nativeScriptLoadShell(NATIVE_BUNDLE_SCRIPT_NAMES);
}
function nativeScriptLoadShell(names: readonly string[]): string {
return names.map((name) => { return names.map((name) => {
const encoded = Buffer.from(readFileSync(rootPath("scripts/native/cicd", name), "utf8"), "utf8").toString("base64"); const encoded = Buffer.from(readFileSync(rootPath("scripts/native/cicd", name), "utf8"), "utf8").toString("base64");
return [ return [
+2 -2
View File
@@ -22,7 +22,7 @@ import { transPath } from "./hwlab-node/runtime-common";
import { configRefGraph, resolveConfigRefString } from "./ops/config-refs"; import { configRefGraph, resolveConfigRefString } from "./ops/config-refs";
import { renderControllerManifests, renderControllerReconcileJob, waitForJobShell } from "./cicd-controller-render"; import { renderControllerManifests, renderControllerReconcileJob, waitForJobShell } from "./cicd-controller-render";
import { runNativeHwlabControlPlaneRefresh } from "./cicd-hwlab-refresh"; import { runNativeHwlabControlPlaneRefresh } from "./cicd-hwlab-refresh";
import { readNativeObjectBundle } from "./cicd-native-bundle"; import { nativeCicdScriptLoadShell, readNativeObjectBundle } from "./cicd-native-bundle";
import { runNativeK8sJob, runNativeTektonPipelineRun } from "./cicd-native"; import { runNativeK8sJob, runNativeTektonPipelineRun } from "./cicd-native";
import type { AdapterSummary, BranchFollowerPhase, BranchFollowerRegistry, ControllerSpec, FollowerSpec, FollowerState, K8sFollowerStateRead, K8sStateRead, NativeCloseoutWaitResult, NativeK8sJobResult, NativeStatusSpec, NativeWorkloadSpec, OutputMode, ParsedOptions, StageTiming, TriggerResult } from "./cicd-types"; import type { AdapterSummary, BranchFollowerPhase, BranchFollowerRegistry, ControllerSpec, FollowerSpec, FollowerState, K8sFollowerStateRead, K8sStateRead, NativeCloseoutWaitResult, NativeK8sJobResult, NativeStatusSpec, NativeWorkloadSpec, OutputMode, ParsedOptions, StageTiming, TriggerResult } from "./cicd-types";
import { import {
@@ -1860,7 +1860,7 @@ function kubeConfigMapFollowerState(registry: BranchFollowerRegistry, options: P
"tmpdir=$(mktemp -d)", "tmpdir=$(mktemp -d)",
"cleanup() { rm -rf \"$tmpdir\"; }", "cleanup() { rm -rf \"$tmpdir\"; }",
"trap cleanup EXIT INT TERM", "trap cleanup EXIT INT TERM",
nativeScriptLoadShell(["read-state-summary.mjs"]), nativeCicdScriptLoadShell(["read-state-summary.mjs"]),
`NAMESPACE=${shQuote(registry.controller.namespace)}`, `NAMESPACE=${shQuote(registry.controller.namespace)}`,
`CONFIGMAP=${shQuote(registry.controller.stateConfigMapName)}`, `CONFIGMAP=${shQuote(registry.controller.stateConfigMapName)}`,
`FOLLOWERS_JSON=${shQuote(JSON.stringify(registry.followers.map((follower) => follower.id)))}`, `FOLLOWERS_JSON=${shQuote(JSON.stringify(registry.followers.map((follower) => follower.id)))}`,