fix: close record repair and verification gaps
This commit is contained in:
1 parent
9251c85fd8
commit
adff599e08
27 files changed
+787
-153
No files matched your search
@@ -13,11 +13,11 @@ export function expectRecordDeleteBody(json: unknown, what: string): void {
|
||||
}
|
||||
|
||||
export function bulkDeleteBody(deleted: number): Record<string, unknown> {
|
||||
return expect.objectContaining({ deleted });
|
||||
return { deleted, warnings: expect.any(Array) };
|
||||
}
|
||||
|
||||
export function importApplyBody(added: number, updated: number, deleted: number): Record<string, unknown> {
|
||||
return expect.objectContaining({ added, updated, deleted });
|
||||
return { added, updated, deleted, warnings: expect.any(Array) };
|
||||
}
|
||||
|
||||
export function expectZoneCreateWarnings(json: unknown): void {
|
||||
|
||||
+8
-24
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
import { COMPOSE_FILE, containerName, project, RESOURCE_PREFIX, RUN_LABEL } from './env';
|
||||
import { COMPOSE_FILE, containerName, project, RUN_LABEL } from './env';
|
||||
import { run, runOk, type ProcOptions, type ProcResult } from './proc';
|
||||
|
||||
export function docker(args: readonly string[], opts: ProcOptions = {}): Promise<ProcResult> {
|
||||
@@ -34,27 +34,11 @@ export interface ProjectResources {
|
||||
}
|
||||
|
||||
export async function projectResources(): Promise<ProjectResources> {
|
||||
const p = project();
|
||||
const byLabel = await dockerOk(['ps', '-a', '--filter', `label=${RUN_LABEL}=${p}`, '--format', '{{.Names}}']);
|
||||
const byName = await dockerOk(['ps', '-a', '--filter', `name=^${p}`, '--format', '{{.Names}}']);
|
||||
const byCompose = await dockerOk(['ps', '-a', '--filter', `label=com.docker.compose.project=${p}`, '--format', '{{.Names}}']);
|
||||
const self = new Set([runnerContainer()]);
|
||||
const containers = [...new Set([...lines(byLabel.stdout), ...lines(byName.stdout), ...lines(byCompose.stdout)])].filter(
|
||||
(n) => !self.has(n) && !/^.+-runner-run-[0-9a-f]+$/.test(n),
|
||||
);
|
||||
const volumes = new Set<string>();
|
||||
for (const filter of [`label=${RUN_LABEL}=${p}`, `label=com.docker.compose.project=${p}`, `name=${p}`]) {
|
||||
const r = await dockerOk(['volume', 'ls', '-q', '--filter', filter]);
|
||||
for (const v of lines(r.stdout)) volumes.add(v);
|
||||
}
|
||||
const networks = new Set<string>();
|
||||
for (const filter of [`label=${RUN_LABEL}=${p}`, `name=${p}`]) {
|
||||
const r = await dockerOk(['network', 'ls', '--format', '{{.Name}}', '--filter', filter]);
|
||||
for (const n of lines(r.stdout)) networks.add(n);
|
||||
}
|
||||
return { containers, volumes: [...volumes], networks: [...networks] };
|
||||
}
|
||||
|
||||
export function isOwnedName(name: string): boolean {
|
||||
return name.startsWith(RESOURCE_PREFIX);
|
||||
const filter = `label=${RUN_LABEL}=${project()}`;
|
||||
const [containers, volumes, networks] = await Promise.all([
|
||||
dockerOk(['ps', '-a', '--filter', filter, '--format', '{{.Names}}']),
|
||||
dockerOk(['volume', 'ls', '-q', '--filter', filter]),
|
||||
dockerOk(['network', 'ls', '--filter', filter, '--format', '{{.Name}}']),
|
||||
]);
|
||||
return { containers: lines(containers.stdout), volumes: lines(volumes.stdout), networks: lines(networks.stdout) };
|
||||
}
|
||||
@@ -108,7 +108,10 @@ export function matchRoute(method: string, apiPath: string): RouteMatch | null {
|
||||
const v = groups[i];
|
||||
if (v === null || v === undefined) return;
|
||||
if (t === 'zone') out.zone = normalizeZoneParam(v);
|
||||
if (t === 'record') out.recordId = /^[0-9]{1,9}$/.test(v) ? Number(v) : null;
|
||||
if (t === 'record' && /^\+?[0-9]+$/.test(v)) {
|
||||
const id = Number(v);
|
||||
if (id > 0 && id <= 0xffffffff) out.recordId = id;
|
||||
}
|
||||
if (t === 'user' || t === 'delegation') out.targetUser = v;
|
||||
});
|
||||
return out;
|
||||
|
||||
Reference in new issue
Block a user