From c1239f4fa0802958e56a124ab52fe1e9ac5513ba Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Fri, 5 Jul 2024 21:34:05 +0200 Subject: [PATCH] WIP variants for each platform - Improve OciRegistryDataTask: group image references by name --- .../sgtsilvio/gradle/oci/OciRegistryDataTask.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciRegistryDataTask.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciRegistryDataTask.kt index daf98fe5..0123d08c 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciRegistryDataTask.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciRegistryDataTask.kt @@ -37,8 +37,8 @@ abstract class OciRegistryDataTask : OciImagesInputTask() { } for ((multiArchImage, imageReferences) in multiArchImageAndReferencesPairs) { blobsDirectory.writeDigestData(multiArchImage.index) - for (imageReference in imageReferences) { // TODO group by name - val repositoryDirectory = repositoriesDirectory.resolve(imageReference.name).createDirectories() + for ((name, tags) in imageReferences.groupBy({ it.name }, { it.tag })) { + val repositoryDirectory = repositoriesDirectory.resolve(name).createDirectories() val layersDirectory = repositoryDirectory.resolve("_layers").createDirectories() val manifestsDirectory = repositoryDirectory.resolve("_manifests").createDirectories() val manifestRevisionsDirectory = manifestsDirectory.resolve("revisions").createDirectories() @@ -57,9 +57,11 @@ abstract class OciRegistryDataTask : OciImagesInputTask() { } val indexDigest = multiArchImage.index.digest manifestRevisionsDirectory.writeDigestLink(indexDigest) - val tagDirectory = manifestsDirectory.resolve("tags").resolve(imageReference.tag).createDirectories() - tagDirectory.writeTagLink(indexDigest) - tagDirectory.resolve("index").createDirectories().writeDigestLink(indexDigest) + for (tag in tags) { + val tagDirectory = manifestsDirectory.resolve("tags").resolve(tag).createDirectories() + tagDirectory.writeTagLink(indexDigest) + tagDirectory.resolve("index").createDirectories().writeDigestLink(indexDigest) + } } } }