fix: 收敛 HWLAB runtime GitOps ConfigMap ownership
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
export function runtimeGitopsScriptsConfigMap({ overlay, scriptsDir, namespace, configMapName }) {
|
||||
const data = {
|
||||
"runtime-gitops-overlay.json": `${JSON.stringify({
|
||||
runtimePath: requiredString(overlay.runtimePath, "overlay.runtimePath"),
|
||||
observability: objectOr(overlay.observability),
|
||||
})}\n`,
|
||||
};
|
||||
for (const name of ["runtime-gitops-observability.mjs", "runtime-gitops-postprocess.mjs", "runtime-gitops-verify.mjs"]) {
|
||||
data[name] = readFileSync(path.join(scriptsDir, name), "utf8");
|
||||
}
|
||||
return {
|
||||
apiVersion: "v1",
|
||||
kind: "ConfigMap",
|
||||
metadata: {
|
||||
name: configMapName,
|
||||
namespace,
|
||||
labels: {
|
||||
"app.kubernetes.io/name": "hwlab-runtime-gitops-scripts",
|
||||
"app.kubernetes.io/part-of": "unidesk-hwlab-control-plane",
|
||||
"app.kubernetes.io/managed-by": "unidesk-host-gitops",
|
||||
"hwlab.pikastech.local/node": overlay.nodeId ?? null,
|
||||
"hwlab.pikastech.local/lane": overlay.lane ?? null,
|
||||
},
|
||||
},
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
function requiredString(value, pathLabel) {
|
||||
if (typeof value !== "string" || value.length === 0) throw new Error(`${pathLabel} must be a non-empty string`);
|
||||
return value;
|
||||
}
|
||||
|
||||
function objectOr(value) {
|
||||
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
||||
}
|
||||
Reference in New Issue
Block a user