Immagine: un manifest semplice, così togliere una :sha- libera gli strati

Con il builder docker-container buildx aggiunge da sé l'attestazione di
provenienza, e l'immagine spinta sul registro è un indice. Gitea tiene
ogni manifest figlio come una versione a sé, sha256:… senza etichetta,
con la configurazione e gli strati: la pulizia del lunedì toglieva solo
l'indice delle :sha- vecchie e gli strati restavano per sempre, mentre i
documenti dicevano che il registro si alleggeriva (rilievo della
revisione, controllato sul codice di Gitea release/v28).

costruisci-immagine.sh costruisce con --provenance=false --sbom=false,
sia l'archivio provato sia l'immagine spinta: ogni etichetta è un
manifest semplice che tiene i suoi strati, e quando nessuna versione li
usa più li cancella la pulizia notturna dei pacchetti di Gitea. Le
versioni sha256:… lo script non le tocca mai, perché l'API non dice se
un indice le rimanda, ma ne scrive il numero, anche nella prova
(versioni-registro.js senza-etichetta); docs/processo.md dice quale
regola di pulizia di Gitea le toglie se compaiono. La CI non ha ancora
pubblicato nulla, perché manca REGISTRY_TOKEN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-21 11:38:53 +02:00
1 parent 46d780c826
commit 086b603801
7 files changed
+120 -25

No files matched your search

+41 -18
View File
@@ -3,23 +3,34 @@
// files it is given: no network, no writes, so it is tested with a JSON file.
//
// node versioni-registro.js <how many to keep> <page.json>...
// node versioni-registro.js senza-etichetta <page.json>...
//
// Each file is a page of the answer of GET /api/v1/packages/{owner}/container/febe of Gitea 28: a list of versions with
// «type», «name», «version» and «created_at» (an empty page may be «[]» or «null»). It prints, oldest first and one per
// line, «version<TAB>created» of the sha-<7 to 40 hex digits> tags of the container package «febe» beyond the N newest
// by creation date. Everything else always stays: main, latest, the X.Y.Z releases (X.Y.Z-rc.N too), the digests
// (sha256:…), any other tag and a sha- tag without a date that can be read. A version found in two pages counts once.
// «type», «name», «version» and «created_at» (an empty page may be «[]» or «null»). Only the versions of the container
// package «febe» count, and a version found in two pages counts once. Both forms print, oldest first and one per line,
// «version<TAB>created».
//
// With a number N: the sha-<7 to 40 hex digits> tags beyond the N newest by creation date. Everything else always
// stays: main, latest, the X.Y.Z releases (X.Y.Z-rc.N too), the digests (sha256:…), any other tag and a sha- tag
// without a date that can be read.
//
// With «senza-etichetta»: the untagged versions, sha256:<64 hex digits>. They are the manifests of an image index,
// which Gitea keeps as versions of their own with the configuration and the layers; nothing here removes them (Gitea
// cannot be asked through this API whether a tag still uses one), the cleanup only says how many there are.
//
// If a file is not a JSON list it exits with 2 and prints nothing: when in doubt nothing is removed.
// Messages are in Italian, like every message of the CI.
const fs = require("fs");
const [keep, ...pages] = process.argv.slice(2);
if (!/^[0-9]+$/.test(keep || "") || pages.length === 0) {
console.error("Uso: node versioni-registro.js <quante tenere> <pagina.json>...");
const [mode, ...pages] = process.argv.slice(2);
const untagged = mode === "senza-etichetta";
if (!(untagged || /^[0-9]+$/.test(mode || "")) || pages.length === 0) {
console.error("Uso: node versioni-registro.js <quante tenere> | senza-etichetta <pagina.json>...");
process.exit(2);
}
const shaTag = /^sha-[0-9a-f]{7,40}$/;
const digest = /^sha256:[0-9a-f]{64}$/;
const versions = new Map();
for (const file of pages) {
let page;
@@ -43,17 +54,29 @@ for (const file of pages) {
}
}
const candidates = [...versions.values()]
.filter((version) => shaTag.test(version.version))
.map((version) => ({
name: version.version,
created: String(version.created_at),
time: Date.parse(version.created_at),
id: Number(version.id) || 0,
}))
.filter((version) => Number.isFinite(version.time))
.sort((a, b) => b.time - a.time || b.id - a.id);
const dated = (version) => ({
name: version.version,
created: String(version.created_at),
time: Date.parse(version.created_at),
id: Number(version.id) || 0,
});
for (const version of candidates.slice(Number(keep)).reverse()) {
let chosen;
if (untagged) {
chosen = [...versions.values()]
.filter((version) => digest.test(version.version))
.map(dated)
.sort((a, b) => (Number.isFinite(a.time) ? a.time : 0) - (Number.isFinite(b.time) ? b.time : 0) || a.id - b.id);
} else {
chosen = [...versions.values()]
.filter((version) => shaTag.test(version.version))
.map(dated)
.filter((version) => Number.isFinite(version.time))
.sort((a, b) => b.time - a.time || b.id - a.id)
.slice(Number(mode))
.reverse();
}
for (const version of chosen) {
process.stdout.write(`${version.name}\t${version.created}\n`);
}