From cddf056925b6f02957bf58282cec2b36f323bd44 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:43:24 +0200 Subject: [PATCH] feat(storage): add ArtifactStore interface --- .../server/core/storage/ArtifactStore.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cameleer-server-core/src/main/java/com/cameleer/server/core/storage/ArtifactStore.java diff --git a/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/ArtifactStore.java b/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/ArtifactStore.java new file mode 100644 index 00000000..8457348c --- /dev/null +++ b/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/ArtifactStore.java @@ -0,0 +1,35 @@ +package com.cameleer.server.core.storage; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Storage abstraction for deployable JAR artifacts. Implementations decide where + * the bytes live (filesystem today; OCI registry / S3 later — see Zot follow-up + * issue #158). Callers never construct filesystem paths themselves. + * + *

The interface is intentionally narrow: enough to upload, fetch, and delete. + * {@link #locator} returns a stable identifier written into + * {@code app_versions.jar_path} so existing rows still resolve. + */ +public interface ArtifactStore { + + /** Persist {@code bytes} of {@code size} bytes under {@code coords}. Idempotent + * on identical content; overwrites on same coords with different content. + * Returns the locator (same as {@link #locator}) for convenience. */ + String put(ArtifactCoordinates coords, InputStream bytes, long size) throws IOException; + + /** Open the artifact for reading. Caller closes. */ + InputStream get(ArtifactCoordinates coords) throws IOException; + + boolean exists(ArtifactCoordinates coords); + + /** Remove the artifact and any backend-specific scaffolding (empty parent dirs, etc.). + * Silently no-ops if the artifact is already absent. */ + void delete(ArtifactCoordinates coords) throws IOException; + + /** Stable identifier for this storage location — written into + * {@code app_versions.jar_path} so existing rows still resolve. For the + * filesystem store this is the absolute path; for OCI it's the ref. */ + String locator(ArtifactCoordinates coords); +}