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
+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) };
|
||||
}
|
||||
Reference in new issue
Block a user