feat(docker): scan/inspect passifs des stacks Compose (tâche 2 SJ-4)
- 4 tables Docker (settings/compose_roots/compose_stacks/stack_services)
+ migration 0004 (timestamps journal monotones)
- templates docker/scan-compose + inspect-compose ; renderTemplate bascule
sur délimiteurs <% %> pour les templates docker/ afin de préserver les
Go-templates {{.ID}} intacts
- dockerScan: parseDockerScan (TDD) + scanDockerStacks (persiste stacks
candidats, complète la détection par labels)
- action docker_scan branchée dans execute (route dédiée, archivage report/log)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,23 @@ const TEMPLATES_ROOT = resolve(process.cwd(), "templates");
|
||||
|
||||
export interface TemplateVars {
|
||||
aptProxy?: string | null;
|
||||
// Docker template vars
|
||||
composeRoots?: string | number | null;
|
||||
composeScanDepth?: string | number | null;
|
||||
stackDir?: string | null;
|
||||
}
|
||||
|
||||
export function renderTemplate(relPath: string, vars: TemplateVars): string {
|
||||
export function renderTemplate(
|
||||
relPath: string,
|
||||
vars: TemplateVars,
|
||||
opts?: { tags?: [string, string] },
|
||||
): string {
|
||||
const tpl = readFileSync(resolve(TEMPLATES_ROOT, relPath), "utf8");
|
||||
// Mustache échappe le HTML par défaut; on désactive (ce sont des scripts shell).
|
||||
return Mustache.render(tpl, vars, {}, { escape: (s) => s });
|
||||
// Les templates Docker contiennent des Go-templates {{...}} : on bascule les
|
||||
// délimiteurs Mustache sur <% %> pour ne pas les interpréter.
|
||||
const tags = opts?.tags ?? (relPath.startsWith("docker/") ? (["<%", "%>"] as [string, string]) : undefined);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return Mustache.render(tpl, vars, {}, { escape: (s: any) => s, ...(tags ? { tags } : {}) } as any);
|
||||
}
|
||||
|
||||
/** Existence par défaut d'un template relatif à templates/. */
|
||||
|
||||
Reference in New Issue
Block a user