diff --git a/core/src/main/java/io/roastedroot/inlay/InlayClient.java b/core/src/main/java/io/roastedroot/inlay/InlayClient.java index ef5e5af..0d64718 100644 --- a/core/src/main/java/io/roastedroot/inlay/InlayClient.java +++ b/core/src/main/java/io/roastedroot/inlay/InlayClient.java @@ -69,6 +69,7 @@ public Path pullByDigest(String imageRef, String digest, Path outputFile) { try { Path tempDir = Files.createTempDirectory("inlay-pull-"); try { + createLayerDirs(containerRef, tempDir); registry.pullArtifact(containerRef, tempDir, true); Path pulled = findWasmFile(tempDir); @@ -163,6 +164,18 @@ private Path cachePath(String digest) { return cacheDir.resolve(safe).resolve("artifact.wasm"); } + private void createLayerDirs(ContainerRef containerRef, Path tempDir) throws IOException { + Descriptor descriptor = registry.getDescriptor(containerRef); + Manifest manifest = Manifest.fromJson(descriptor.getJson()); + for (Layer layer : manifest.getLayers()) { + String title = layer.getAnnotations().get("org.opencontainers.image.title"); + if (title != null) { + Path layerPath = tempDir.resolve(title); + Files.createDirectories(layerPath.getParent()); + } + } + } + private static Path findWasmFile(Path dir) throws IOException { try (Stream stream = Files.walk(dir)) { return stream.filter(Files::isRegularFile)