Files
lilleman 0644ec8f5a
CI / full-gate (push) Successful in 2m40s
Mirror / github-mirror (push) Successful in 0s
CI: nightly registry cleanup - prune hash images not release-tagged nor a branch head
2026-07-04 09:18:07 +02:00

32 lines
949 B
TypeScript

const hashTag = /^[0-9a-f]{40}$/;
const manifestVersion = /^sha256:[0-9a-f]{64}$/;
export type HashTagPlan = {
deletions: string[];
keptTags: string[];
};
export function planHashTagDeletions(input: {
branchHeadShas: string[];
releaseTagShas: string[];
versions: string[];
}): HashTagPlan {
const keep = new Set([...input.branchHeadShas, ...input.releaseTagShas]);
const deletions: string[] = [];
const keptTags: string[] = [];
for (const version of input.versions) {
if (manifestVersion.test(version)) continue;
if (hashTag.test(version) && !keep.has(version)) deletions.push(version);
else keptTags.push(version);
}
return { deletions, keptTags };
}
export function selectOrphanedManifests(input: {
referencedDigests: string[];
versions: string[];
}): string[] {
const referenced = new Set(input.referencedDigests);
return input.versions.filter((v) => manifestVersion.test(v) && !referenced.has(v));
}