refactor: 移除顶层 defaults 配置段,简化为 target 显式字段 > 代码内置默认值
- 移除 DefaultsConfig 类型、ProbeConfig.defaults 字段 - 移除 CheckerSchemas.defaults、ResolveContext.defaults、CheckerValidationInput.defaults - 更新所有 checker schema/resolve/validate 删除 defaults 合并逻辑 - 更新 config-loader 不再读取传递 defaults - 更新测试、README、DEVELOPMENT、probes.example.yaml - 重新生成 probe-config.schema.json(不含 defaults) - 同步 delta specs 到主规范 - 归档 openspec change
This commit is contained in:
@@ -4,9 +4,8 @@ import type { CheckerValidationInput } from "../../../../../src/server/checker/r
|
||||
|
||||
import { validateTcpConfig } from "../../../../../src/server/checker/runner/tcp/validate";
|
||||
|
||||
function makeInput(targets: unknown[], defaults?: Record<string, unknown>): CheckerValidationInput {
|
||||
function makeInput(targets: unknown[]): CheckerValidationInput {
|
||||
return {
|
||||
defaults: defaults ?? {},
|
||||
targets: targets as CheckerValidationInput["targets"],
|
||||
};
|
||||
}
|
||||
@@ -152,40 +151,4 @@ describe("validateTcpConfig", () => {
|
||||
const issues = validateTcpConfig(makeInput([{ http: { url: "http://example.com" }, id: "t1", type: "http" }]));
|
||||
expect(issues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("defaults.tcp 合法字段无错误", () => {
|
||||
const issues = validateTcpConfig(
|
||||
makeInput([{ id: "t1", tcp: { host: "127.0.0.1", port: 80 }, type: "tcp" }], {
|
||||
tcp: { bannerReadTimeout: 1000, maxBannerBytes: "8KB" },
|
||||
}),
|
||||
);
|
||||
expect(issues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("defaults.tcp 未知字段", () => {
|
||||
const issues = validateTcpConfig(
|
||||
makeInput([{ id: "t1", tcp: { host: "127.0.0.1", port: 80 }, type: "tcp" }], {
|
||||
tcp: { bannerReadTimeout: 1000, host: "127.0.0.1" },
|
||||
}),
|
||||
);
|
||||
expect(issues.some((i) => i.message.includes("未知字段"))).toBe(true);
|
||||
});
|
||||
|
||||
test("defaults.tcp bannerReadTimeout 非法", () => {
|
||||
const issues = validateTcpConfig(
|
||||
makeInput([{ id: "t1", tcp: { host: "127.0.0.1", port: 80 }, type: "tcp" }], {
|
||||
tcp: { bannerReadTimeout: "slow" },
|
||||
}),
|
||||
);
|
||||
expect(issues.some((i) => i.path.includes("bannerReadTimeout"))).toBe(true);
|
||||
});
|
||||
|
||||
test("defaults.tcp maxBannerBytes 非法", () => {
|
||||
const issues = validateTcpConfig(
|
||||
makeInput([{ id: "t1", tcp: { host: "127.0.0.1", port: 80 }, type: "tcp" }], {
|
||||
tcp: { maxBannerBytes: true },
|
||||
}),
|
||||
);
|
||||
expect(issues.some((i) => i.path.includes("maxBannerBytes"))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user