feat: add JD01 YAML-first deployment support
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Responsibility: Resolve YAML-first web-probe sentinel registry entries into one selected sentinel config graph.
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { rootPath } from "./config";
|
||||
import { readWebProbeSentinelConfigRefTarget, type WebProbeSentinelTemplateContext } from "./hwlab-node-web-sentinel-config-ref";
|
||||
import { HWLAB_WEB_PROBE_SENTINEL_CONFIG_REF_KEYS, type HwlabRuntimeLaneSpec, type HwlabRuntimeWebProbeSentinelConfigRefKey, type HwlabRuntimeWebProbeSentinelRegistryItemSpec } from "./hwlab-node-lanes";
|
||||
|
||||
export interface ResolvedWebProbeSentinel {
|
||||
@@ -110,7 +111,7 @@ function resolveRegistrySentinel(spec: HwlabRuntimeLaneSpec, registry: readonly
|
||||
const ids = registry.map((item) => item.id).join(", ");
|
||||
throw new Error(`unknown web-probe sentinel ${sentinelId ?? "-"} for ${spec.nodeId}/${spec.lane}; available: ${ids}`);
|
||||
}
|
||||
const target = readConfigRefRecord(selected.configRef);
|
||||
const target = readConfigRefRecord(selected.configRef, spec);
|
||||
const targetId = optionalStringAt(target, "id") ?? selected.id;
|
||||
if (targetId !== selected.id) {
|
||||
throw new Error(`${selected.configRef}.id=${targetId} does not match registry id ${selected.id}`);
|
||||
@@ -151,13 +152,14 @@ function normalizeSentinelConfigRefs(target: Record<string, unknown>, ref: strin
|
||||
return Object.fromEntries(HWLAB_WEB_PROBE_SENTINEL_CONFIG_REF_KEYS.map((key) => [key, normalized[key]])) as Record<HwlabRuntimeWebProbeSentinelConfigRefKey, string>;
|
||||
}
|
||||
|
||||
function readConfigRefRecord(ref: string): Record<string, unknown> {
|
||||
const target = readConfigRefTarget(ref);
|
||||
function readConfigRefRecord(ref: string, context: WebProbeSentinelTemplateContext): Record<string, unknown> {
|
||||
const target = readConfigRefTarget(ref, context);
|
||||
if (!isRecord(target)) throw new Error(`${ref} must point to a YAML object`);
|
||||
return target;
|
||||
}
|
||||
|
||||
export function readConfigRefTarget(ref: string): unknown {
|
||||
export function readConfigRefTarget(ref: string, context?: WebProbeSentinelTemplateContext): unknown {
|
||||
if (context !== undefined) return readWebProbeSentinelConfigRefTarget(context, ref);
|
||||
const [file, path, extra] = ref.split("#");
|
||||
if (extra !== undefined || file === undefined || path === undefined || file.length === 0 || path.length === 0) {
|
||||
throw new Error(`${ref} must use path/to/file.yaml#object.path syntax`);
|
||||
|
||||
Reference in New Issue
Block a user