mirror of
https://github.com/tale/headplane.git
synced 2026-08-27 15:37:04 +00:00
fix: properly support default/fallback in arktype
This commit is contained in:
@@ -133,6 +133,11 @@ export default class DockerIntegration extends Integration<T> {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
log.debug(
|
||||||
|
'config',
|
||||||
|
'Requesting Docker containers with filters: %s',
|
||||||
|
qp.toString(),
|
||||||
|
);
|
||||||
const res = await this.client.request({
|
const res = await this.client.request({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: `/v1.30/containers/json?${qp.toString()}`,
|
path: `/v1.30/containers/json?${qp.toString()}`,
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ function deepMerge<T>(target: T, source: DeepPartial<T>): T {
|
|||||||
|
|
||||||
for (const key in source) {
|
for (const key in source) {
|
||||||
const val = source[key];
|
const val = source[key];
|
||||||
if (val === undefined) {
|
if (val === undefined || val === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ const agentConfig = type({
|
|||||||
work_dir: 'string = "/var/lib/headplane/agent"',
|
work_dir: 'string = "/var/lib/headplane/agent"',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const partialAgentConfig = type({
|
||||||
|
enabled: stringToBool,
|
||||||
|
host_name: 'string | undefined',
|
||||||
|
pre_authkey: 'string | undefined',
|
||||||
|
cache_ttl: 'number.integer | undefined',
|
||||||
|
cache_path: 'string | undefined',
|
||||||
|
executable_path: 'string | undefined',
|
||||||
|
work_dir: 'string | undefined',
|
||||||
|
}).partial();
|
||||||
|
|
||||||
const dockerConfig = type({
|
const dockerConfig = type({
|
||||||
enabled: stringToBool,
|
enabled: stringToBool,
|
||||||
container_name: 'string = ""',
|
container_name: 'string = ""',
|
||||||
@@ -63,6 +73,13 @@ const dockerConfig = type({
|
|||||||
socket: 'string = "unix:///var/run/docker.sock"',
|
socket: 'string = "unix:///var/run/docker.sock"',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const partialDockerConfig = type({
|
||||||
|
enabled: stringToBool,
|
||||||
|
container_name: 'string | undefined',
|
||||||
|
container_label: 'string | undefined',
|
||||||
|
socket: 'string | undefined',
|
||||||
|
}).partial();
|
||||||
|
|
||||||
const kubernetesConfig = type({
|
const kubernetesConfig = type({
|
||||||
enabled: stringToBool,
|
enabled: stringToBool,
|
||||||
pod_name: 'string',
|
pod_name: 'string',
|
||||||
@@ -78,13 +95,13 @@ const integrationConfig = type({
|
|||||||
'kubernetes?': kubernetesConfig,
|
'kubernetes?': kubernetesConfig,
|
||||||
'proc?': procConfig,
|
'proc?': procConfig,
|
||||||
'agent?': agentConfig,
|
'agent?': agentConfig,
|
||||||
}).onDeepUndeclaredKey('reject');
|
});
|
||||||
|
|
||||||
const partialIntegrationConfig = type({
|
const partialIntegrationConfig = type({
|
||||||
'docker?': dockerConfig.partial(),
|
'docker?': partialDockerConfig,
|
||||||
'kubernetes?': kubernetesConfig.partial(),
|
'kubernetes?': kubernetesConfig.partial(),
|
||||||
'proc?': procConfig.partial(),
|
'proc?': procConfig.partial(),
|
||||||
'agent?': agentConfig.partial(),
|
'agent?': partialAgentConfig,
|
||||||
}).partial();
|
}).partial();
|
||||||
|
|
||||||
export const headplaneConfig = type({
|
export const headplaneConfig = type({
|
||||||
|
|||||||
Reference in New Issue
Block a user