another take on prune images

This commit is contained in:
Girish Ramakrishnan
2023-08-21 22:16:59 +05:30
parent f152331615
commit 4b6d4fe6be

View File

@@ -62,7 +62,8 @@ async function pruneInfraImages() {
for (const line of lines) {
if (!line) continue;
const [, repo, tag, digest] = line.split(' '); // [ ID, Repo, Tag, Digest ]
if (!parsedTag.repository.endsWith(repo)) continue; // some other repo
const normalizedRepo = repo.replace('registry.ipv6.docker.com/', '').replace('registry-1.docker.io/', '').replace('registry.docker.com/', '');
if (!parsedTag.repository.endsWith(normalizedRepo)) continue; // some other repo
if (imageName === `${repo}:${tag}@${digest}`) continue; // the image we want to keep
const imageIdToPrune = tag === '<none>' ? `${repo}@${digest}` : `${repo}:${tag}`; // untagged, use digest