mirror of
https://github.com/tale/headplane.git
synced 2026-07-26 15:58:14 +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({
|
||||
method: 'GET',
|
||||
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) {
|
||||
const val = source[key];
|
||||
if (val === undefined) {
|
||||
if (val === undefined || val === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user