feat(cicd): add warning-only feature config validation
This commit is contained in:
@@ -26,8 +26,6 @@ if (overlay?.observability?.prometheusOperator === false) {
|
||||
}
|
||||
if (overlay?.codeAgentRuntime?.enabled && overlay.codeAgentRuntime.kafkaEventBridge?.enabled) {
|
||||
checks.push("code-agent-runtime-kafka-event-bridge-enabled");
|
||||
verifyTransactionalProjectionAuthority(overlay.codeAgentRuntime.kafkaEventBridge);
|
||||
verifyCodeAgentRuntimeWorkloads();
|
||||
}
|
||||
|
||||
console.error(JSON.stringify({ event: "unidesk-runtime-gitops-verify", ok: true, runtimePath, checks }));
|
||||
@@ -43,63 +41,6 @@ function findPrometheusOperatorResources() {
|
||||
return refs;
|
||||
}
|
||||
|
||||
function verifyTransactionalProjectionAuthority(kafka) {
|
||||
const expected = {
|
||||
directPublish: false,
|
||||
liveKafkaSse: false,
|
||||
kafkaRefreshReplay: false,
|
||||
transactionalProjector: true,
|
||||
projectionOutboxRelay: true,
|
||||
projectionRealtime: true,
|
||||
};
|
||||
const actual = Object.fromEntries(Object.keys(expected).map((name) => [name, kafka.features?.[name]]));
|
||||
const invalid = Object.entries(expected).filter(([name, value]) => actual[name] !== value).map(([name]) => name);
|
||||
if (invalid.length > 0) fail("kafka-event-bridge-authority-invalid", { invalid, expected, actual });
|
||||
}
|
||||
|
||||
function verifyCodeAgentRuntimeWorkloads() {
|
||||
const expectedByWorkload = {
|
||||
"hwlab-cloud-api": {
|
||||
HWLAB_KAFKA_ENABLED: "true",
|
||||
HWLAB_KAFKA_AGENTRUN_EVENT_CONSUME_ENABLED: "true",
|
||||
HWLAB_KAFKA_DIRECT_PUBLISH_ENABLED: "false",
|
||||
HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED: "false",
|
||||
HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED: "false",
|
||||
HWLAB_KAFKA_TRANSACTIONAL_PROJECTOR_ENABLED: "true",
|
||||
HWLAB_KAFKA_PROJECTION_OUTBOX_RELAY_ENABLED: "true",
|
||||
HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED: "true",
|
||||
},
|
||||
"hwlab-cloud-web": {
|
||||
HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED: "false",
|
||||
HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED: "false",
|
||||
HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED: "true",
|
||||
},
|
||||
};
|
||||
const found = new Set();
|
||||
for (const file of listYamlFiles(runtimeDir)) {
|
||||
const rel = path.relative(repoDir, file);
|
||||
for (const document of parseStructuredDocuments(readFileSync(file, "utf8"), file)) {
|
||||
const items = isKubernetesList(document) ? document.items : [document];
|
||||
for (const item of items) {
|
||||
const workloadName = String(item?.metadata?.labels?.["app.kubernetes.io/name"] ?? item?.metadata?.name ?? "");
|
||||
const expected = expectedByWorkload[workloadName];
|
||||
if (!expected) continue;
|
||||
const container = item?.spec?.template?.spec?.containers?.find((candidate) => candidate?.name === workloadName);
|
||||
if (!container) fail("code-agent-runtime-container-missing", { file: rel, workload: workloadName, container: workloadName });
|
||||
if (!Array.isArray(container.env)) fail("code-agent-runtime-env-missing", { file: rel, workload: workloadName, container: workloadName });
|
||||
const actual = Object.fromEntries(container.env.filter((item) => typeof item?.name === "string").map((item) => [item.name, item.value]));
|
||||
const invalid = Object.entries(expected)
|
||||
.filter(([name, value]) => actual[name] !== value)
|
||||
.map(([name, value]) => ({ name, expected: value, actual: actual[name] ?? null }));
|
||||
if (invalid.length > 0) fail("code-agent-runtime-capability-env-invalid", { file: rel, workload: workloadName, container: workloadName, invalid });
|
||||
found.add(workloadName);
|
||||
}
|
||||
}
|
||||
}
|
||||
const missing = Object.keys(expectedByWorkload).filter((workloadName) => !found.has(workloadName));
|
||||
if (missing.length > 0) fail("code-agent-runtime-workload-missing", { runtimePath, missing });
|
||||
}
|
||||
|
||||
function splitYamlDocuments(text) {
|
||||
return text.split(/^---[ \t]*(?:#.*)?$/mu).map((doc) => doc.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user