SYS-11240 Translate all code comments from French to English

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pascal GUINETandClaude Opus 4.6 authored and Jarek Krochmalski committed 2026-06-16 09:08:46 +02:00
1 parent eb5cf32d68
commit 0eaf52fa66
3 files changed
+35 -35

No files matched your search

+29 -29
View File
@@ -3168,24 +3168,24 @@ export async function getRegistryAuth(
return { baseUrl, orgPath: parsed.path, authHeader }; return { baseUrl, orgPath: parsed.path, authHeader };
} }
// --- Harbor fallback pour le catalog et la recherche d'images --- // --- Harbor fallback for catalog and image search ---
// Harbor interdit l'accès au endpoint V2 _catalog pour les robots. // Harbor denies access to the V2 _catalog endpoint for robot accounts.
// On détecte Harbor et on utilise l'API projet native en fallback. // We detect Harbor and use the native project API as a fallback.
/** Cache de détection Harbor par host (TTL 5 min) */ /** Harbor detection cache per host (TTL 5 min) */
const harborDetectionCache = new Map<string, { isHarbor: boolean; ts: number }>(); const harborDetectionCache = new Map<string, { isHarbor: boolean; ts: number }>();
const HARBOR_CACHE_TTL = 5 * 60 * 1000; const HARBOR_CACHE_TTL = 5 * 60 * 1000;
export interface HarborCatalogResult { export interface HarborCatalogResult {
repositories: string[]; repositories: string[];
/** Curseur de pagination : "harbor:<page>" ou null si dernière page */ /** Pagination cursor: "harbor:<page>" or null if last page */
nextLast: string | null; nextLast: string | null;
} }
/** /**
* Détecte si un registry est une instance Harbor. * Detects whether a registry is a Harbor instance.
* Vérifie service="harbor-registry" dans le header WWW-Authenticate de /v2/, * Checks for service="harbor-registry" in the WWW-Authenticate header from /v2/,
* puis confirme via /api/v2.0/ping. Résultat mis en cache 5 min par host. * then confirms via /api/v2.0/ping. Result is cached for 5 min per host.
*/ */
export async function isHarborRegistry(registryUrl: string): Promise<boolean> { export async function isHarborRegistry(registryUrl: string): Promise<boolean> {
const parsed = parseRegistryUrl(registryUrl); const parsed = parseRegistryUrl(registryUrl);
@@ -3200,14 +3200,14 @@ export async function isHarborRegistry(registryUrl: string): Promise<boolean> {
try { try {
const baseUrl = `https://${host}`; const baseUrl = `https://${host}`;
// Étape 1 : vérifier le header WWW-Authenticate de /v2/ // Step 1: check the WWW-Authenticate header from /v2/
const challengeResp = await fetch(`${baseUrl}/v2/`, { const challengeResp = await fetch(`${baseUrl}/v2/`, {
method: 'GET', method: 'GET',
headers: { 'User-Agent': 'Dockhand/1.0' } headers: { 'User-Agent': 'Dockhand/1.0' }
}); });
const wwwAuth = challengeResp.headers.get('WWW-Authenticate') || ''; const wwwAuth = challengeResp.headers.get('WWW-Authenticate') || '';
if (wwwAuth.toLowerCase().includes('service="harbor-registry"')) { if (wwwAuth.toLowerCase().includes('service="harbor-registry"')) {
// Étape 2 : confirmer via /api/v2.0/ping // Step 2: confirm via /api/v2.0/ping
const pingResp = await fetch(`${baseUrl}/api/v2.0/ping`, { const pingResp = await fetch(`${baseUrl}/api/v2.0/ping`, {
method: 'GET', method: 'GET',
headers: { 'User-Agent': 'Dockhand/1.0' } headers: { 'User-Agent': 'Dockhand/1.0' }
@@ -3220,7 +3220,7 @@ export async function isHarborRegistry(registryUrl: string): Promise<boolean> {
} }
} }
} catch { } catch {
// En cas d'erreur réseau, on considère que ce n'est pas Harbor // On network error, assume it's not Harbor
} }
harborDetectionCache.set(host, { isHarbor, ts: Date.now() }); harborDetectionCache.set(host, { isHarbor, ts: Date.now() });
@@ -3228,7 +3228,7 @@ export async function isHarborRegistry(registryUrl: string): Promise<boolean> {
} }
/** /**
* Construit le header Basic auth pour l'API Harbor à partir d'un objet registry. * Builds the Basic auth header for the Harbor API from a registry object.
*/ */
function getHarborBasicAuth(registry: { username?: string | null; password?: string | null }): string | null { function getHarborBasicAuth(registry: { username?: string | null; password?: string | null }): string | null {
if (registry.username && registry.password) { if (registry.username && registry.password) {
@@ -3238,10 +3238,10 @@ function getHarborBasicAuth(registry: { username?: string | null; password?: str
} }
/** /**
* Liste les repositories via l'API projet Harbor. * Lists repositories via the Harbor project API.
* Si orgPath est défini → un seul projet. Sinon → énumère tous les projets accessibles. * If orgPath is set, queries a single project. Otherwise, enumerates all accessible projects.
* @param page - numéro de page (1-based) * @param page - page number (1-based)
* @param pageSize - nombre de résultats par page * @param pageSize - number of results per page
*/ */
export async function harborListRepositories( export async function harborListRepositories(
registry: { url: string; username?: string | null; password?: string | null }, registry: { url: string; username?: string | null; password?: string | null },
@@ -3263,13 +3263,13 @@ export async function harborListRepositories(
let totalCount = 0; let totalCount = 0;
if (orgPath) { if (orgPath) {
// Un seul projet : le path sans le slash initial // Single project: path without the leading slash
const project = orgPath.replace(/^\//, ''); const project = orgPath.replace(/^\//, '');
const url = `${baseUrl}/projects/${encodeURIComponent(project)}/repositories?page=${page}&page_size=${pageSize}`; const url = `${baseUrl}/projects/${encodeURIComponent(project)}/repositories?page=${page}&page_size=${pageSize}`;
const resp = await fetch(url, { headers }); const resp = await fetch(url, { headers });
if (!resp.ok) { if (!resp.ok) {
throw new Error(`Harbor API erreur ${resp.status} pour le projet ${project}`); throw new Error(`Harbor API error ${resp.status} for project ${project}`);
} }
totalCount = parseInt(resp.headers.get('X-Total-Count') || '0', 10); totalCount = parseInt(resp.headers.get('X-Total-Count') || '0', 10);
@@ -3278,15 +3278,15 @@ export async function harborListRepositories(
repositories.push(r.name); repositories.push(r.name);
} }
} else { } else {
// Pas d'orgPath : énumérer tous les projets accessibles // No orgPath: enumerate all accessible projects
const projectsResp = await fetch(`${baseUrl}/projects?page=1&page_size=100`, { headers }); const projectsResp = await fetch(`${baseUrl}/projects?page=1&page_size=100`, { headers });
if (!projectsResp.ok) { if (!projectsResp.ok) {
throw new Error(`Harbor API erreur ${projectsResp.status} pour la liste des projets`); throw new Error(`Harbor API error ${projectsResp.status} when listing projects`);
} }
const projects: Array<{ name: string }> = await projectsResp.json(); const projects: Array<{ name: string }> = await projectsResp.json();
// Paginer les repos du premier projet correspondant à la page demandée // Paginate repos from the first matching project
// Pour simplifier, on concatène tous les repos de tous les projets // For simplicity, concatenate all repos from all projects
for (const proj of projects) { for (const proj of projects) {
const url = `${baseUrl}/projects/${encodeURIComponent(proj.name)}/repositories?page=1&page_size=100`; const url = `${baseUrl}/projects/${encodeURIComponent(proj.name)}/repositories?page=1&page_size=100`;
const resp = await fetch(url, { headers }); const resp = await fetch(url, { headers });
@@ -3300,7 +3300,7 @@ export async function harborListRepositories(
totalCount = repositories.length; totalCount = repositories.length;
} }
// Calculer si il y a une page suivante // Check if there is a next page
const hasMore = orgPath ? (page * pageSize < totalCount) : false; const hasMore = orgPath ? (page * pageSize < totalCount) : false;
const nextLast = hasMore ? `harbor:${page + 1}` : null; const nextLast = hasMore ? `harbor:${page + 1}` : null;
@@ -3308,9 +3308,9 @@ export async function harborListRepositories(
} }
/** /**
* Recherche des repositories via l'API Harbor avec filtre q=name=~{term}. * Searches repositories via the Harbor API using filter q=name=~{term}.
* Parcourt tous les projets accessibles (ou un seul si orgPath défini). * Iterates through all accessible projects (or a single one if orgPath is set).
* Double vérification substring côté client. * Client-side substring double-check.
*/ */
export async function harborSearchRepositories( export async function harborSearchRepositories(
registry: { url: string; username?: string | null; password?: string | null }, registry: { url: string; username?: string | null; password?: string | null },
@@ -3331,7 +3331,7 @@ export async function harborSearchRepositories(
const termLower = term.toLowerCase(); const termLower = term.toLowerCase();
const results: string[] = []; const results: string[] = [];
// Déterminer les projets à parcourir // Determine which projects to iterate through
let projectNames: string[]; let projectNames: string[];
if (orgPath) { if (orgPath) {
projectNames = [orgPath.replace(/^\//, '')]; projectNames = [orgPath.replace(/^\//, '')];
@@ -3342,7 +3342,7 @@ export async function harborSearchRepositories(
projectNames = projects.map(p => p.name); projectNames = projects.map(p => p.name);
} }
// Chercher dans chaque projet avec le filtre Harbor // Search each project using the Harbor filter
for (const proj of projectNames) { for (const proj of projectNames) {
if (results.length >= limit) break; if (results.length >= limit) break;
@@ -3353,7 +3353,7 @@ export async function harborSearchRepositories(
const repos: Array<{ name: string }> = await resp.json(); const repos: Array<{ name: string }> = await resp.json();
for (const r of repos) { for (const r of repos) {
// Double vérification côté client // Client-side double-check
if (r.name.toLowerCase().includes(termLower)) { if (r.name.toLowerCase().includes(termLower)) {
results.push(r.name); results.push(r.name);
if (results.length >= limit) break; if (results.length >= limit) break;
+5 -5
View File
@@ -24,8 +24,8 @@ export const GET: RequestHandler = async ({ url }) => {
return json({ error: 'Docker Hub does not support catalog listing. Please use search instead.' }, { status: 400 }); return json({ error: 'Docker Hub does not support catalog listing. Please use search instead.' }, { status: 400 });
} }
// Fallback Harbor : l'endpoint _catalog est interdit pour les robots Harbor. // Harbor fallback: the _catalog endpoint is forbidden for Harbor robot accounts.
// On utilise l'API projet native à la place. // Use the native project API instead.
if (await isHarborRegistry(registry.url)) { if (await isHarborRegistry(registry.url)) {
return handleHarborCatalog(registry, lastParam); return handleHarborCatalog(registry, lastParam);
} }
@@ -122,8 +122,8 @@ export const GET: RequestHandler = async ({ url }) => {
}; };
/** /**
* Gère le catalog pour un registry Harbor via l'API projet native. * Handles catalog listing for a Harbor registry via the native project API.
* Décode le curseur "harbor:N" pour la pagination. * Decodes the "harbor:N" cursor for pagination.
*/ */
async function handleHarborCatalog( async function handleHarborCatalog(
registry: { url: string; username?: string | null; password?: string | null }, registry: { url: string; username?: string | null; password?: string | null },
@@ -131,7 +131,7 @@ async function handleHarborCatalog(
): Promise<Response> { ): Promise<Response> {
const { path: orgPath } = parseRegistryUrl(registry.url); const { path: orgPath } = parseRegistryUrl(registry.url);
// Décoder le curseur Harbor : "harbor:<page>" → numéro de page // Decode the Harbor cursor: "harbor:<page>" → page number
let page = 1; let page = 1;
if (lastParam?.startsWith('harbor:')) { if (lastParam?.startsWith('harbor:')) {
page = parseInt(lastParam.substring(7), 10) || 1; page = parseInt(lastParam.substring(7), 10) || 1;
+1 -1
View File
@@ -127,7 +127,7 @@ async function tryDirectImageLookup(registry: any, imageName: string): Promise<b
// Search through catalog (slow for large registries, limited to first few pages) // Search through catalog (slow for large registries, limited to first few pages)
async function searchCatalog(registry: any, term: string, limit: number): Promise<string[]> { async function searchCatalog(registry: any, term: string, limit: number): Promise<string[]> {
// Fallback Harbor : utiliser l'API projet native pour la recherche // Harbor fallback: use the native project API for search
if (await isHarborRegistry(registry.url)) { if (await isHarborRegistry(registry.url)) {
const { path: orgPath } = parseRegistryUrl(registry.url); const { path: orgPath } = parseRegistryUrl(registry.url);
return harborSearchRepositories(registry, term, orgPath, limit); return harborSearchRepositories(registry, term, orgPath, limit);