fix: YAML-first 治理 CI/CD target (#919)
* docs: specify cicd yaml target governance * fix: resolve cicd targets from yaml --------- Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// SPEC: PJ2026-01060307 控制面模块化 draft-2026-06-25-p0. config module for scripts/src/platform-infra-observability.ts.
|
||||
// SPEC: PJ2026-01060308 cicd-yaml-targets draft-2026-06-25-cicd-yaml-targets.
|
||||
|
||||
// Moved mechanically from scripts/src/platform-infra-observability.ts:370-514 for #903.
|
||||
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
import type { ImageSpec, ObservabilityConfig, ObservabilityTarget, OtlpPorts, ServiceConnection } from "./types";
|
||||
import { assertKnownEnabledTarget, parseStatusEndpoint } from "./actions";
|
||||
import { apiPathField, arrayOfRecords, asRecord, booleanField, configFile, configLabel, enumField, integerField, kubernetesNameField, numberArrayField, objectField, portField, stringArrayField, stringField } from "./types";
|
||||
import { configRefGraph, resolveConfigRefString } from "../ops/config-refs";
|
||||
|
||||
export function readObservabilityConfig(): ObservabilityConfig {
|
||||
const parsed = Bun.YAML.parse(readFileSync(configFile, "utf8")) as unknown;
|
||||
@@ -134,12 +136,33 @@ export function parseOtlpPorts(record: Record<string, unknown>, path: string): O
|
||||
|
||||
export function parseServiceConnection(record: Record<string, unknown>, index: number): ServiceConnection {
|
||||
const path = `instrumentation.serviceConnections[${index}]`;
|
||||
const refs = record.configRefs === undefined ? null : objectField(record, "configRefs", path);
|
||||
const configRefs = refs === null
|
||||
? {}
|
||||
: {
|
||||
targetNode: stringField(refs, "targetNode", `${path}.configRefs`),
|
||||
lane: stringField(refs, "lane", `${path}.configRefs`),
|
||||
namespace: stringField(refs, "namespace", `${path}.configRefs`),
|
||||
};
|
||||
return {
|
||||
serviceName: stringField(record, "serviceName", path),
|
||||
owningRepo: stringField(record, "owningRepo", path),
|
||||
targetNode: stringField(record, "targetNode", path),
|
||||
lane: stringField(record, "lane", path),
|
||||
namespace: kubernetesNameField(record, "namespace", path),
|
||||
targetNode: refs === null ? stringField(record, "targetNode", path) : resolveConfigRefString(configRefs.targetNode, `${path}.configRefs.targetNode`),
|
||||
lane: refs === null ? stringField(record, "lane", path) : resolveConfigRefString(configRefs.lane, `${path}.configRefs.lane`),
|
||||
namespace: refs === null ? kubernetesNameField(record, "namespace", path) : kubernetesNameValue(resolveConfigRefString(configRefs.namespace, `${path}.configRefs.namespace`), `${path}.configRefs.namespace`),
|
||||
configRefs,
|
||||
configRefGraph: refs === null
|
||||
? []
|
||||
: configRefGraph([
|
||||
{ id: `${path}.targetNode`, ref: configRefs.targetNode },
|
||||
{ id: `${path}.lane`, ref: configRefs.lane },
|
||||
{ id: `${path}.namespace`, ref: configRefs.namespace },
|
||||
]),
|
||||
requiredSpans: stringArrayField(record, "requiredSpans", path),
|
||||
};
|
||||
}
|
||||
|
||||
function kubernetesNameValue(value: string, path: string): string {
|
||||
if (!/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/u.test(value)) throw new Error(`${configLabel}.${path} must resolve to a Kubernetes name`);
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user