fix: properly support default/fallback in arktype

This commit is contained in:
Aarnav Tale 2025-05-23 16:23:44 -04:00
parent 769674ab07
commit d25e5fd883
3 changed files with 26 additions and 4 deletions

View file

@ -56,6 +56,16 @@ const agentConfig = type({
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({
enabled: stringToBool,
container_name: 'string = ""',
@ -63,6 +73,13 @@ const dockerConfig = type({
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({
enabled: stringToBool,
pod_name: 'string',
@ -78,13 +95,13 @@ const integrationConfig = type({
'kubernetes?': kubernetesConfig,
'proc?': procConfig,
'agent?': agentConfig,
}).onDeepUndeclaredKey('reject');
});
const partialIntegrationConfig = type({
'docker?': dockerConfig.partial(),
'docker?': partialDockerConfig,
'kubernetes?': kubernetesConfig.partial(),
'proc?': procConfig.partial(),
'agent?': agentConfig.partial(),
'agent?': partialAgentConfig,
}).partial();
export const headplaneConfig = type({