diff --git a/.gitignore b/.gitignore index f2500736..326785dc 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ target/ oci/ !src/test/resources/oci/ !src/test/resources/oci/**/*.json +!src/test/resources/archives/*.zip diff --git a/src/main/java/land/oras/Registry.java b/src/main/java/land/oras/Registry.java index 32581eeb..1accf5a7 100644 --- a/src/main/java/land/oras/Registry.java +++ b/src/main/java/land/oras/Registry.java @@ -425,7 +425,7 @@ public Layer pushBlob(ContainerRef containerRef, Path blob, Map LOG.debug("Digest: {}", digest); ContainerRef ref = containerRef.forRegistry(this).checkBlocked(this); if (ref.isInsecure(this) && !this.isInsecure()) { - return asInsecure().pushBlob(containerRef, blob, annotations); + return asInsecure().pushBlob(ref, blob, annotations); } // This might not works with registries performing HEAD request if (hasBlob(ref.withDigest(digest))) { @@ -453,8 +453,8 @@ public Layer pushBlob(ContainerRef containerRef, Path blob, Map String location = response.headers().get(Const.LOCATION_HEADER.toLowerCase()); // Ensure location is absolute URI if (!location.startsWith("http") && !location.startsWith("https")) { - location = "%s://%s/%s" - .formatted(getScheme(), containerRef.getApiRegistry(this), location.replaceFirst("^/", "")); + location = + "%s://%s/%s".formatted(getScheme(), ref.getApiRegistry(this), location.replaceFirst("^/", "")); } LOG.debug("Location header: {}", location); @@ -465,7 +465,7 @@ public Layer pushBlob(ContainerRef containerRef, Path blob, Map uploadURI, Map.of(Const.CONTENT_TYPE_HEADER, Const.APPLICATION_OCTET_STREAM_HEADER_VALUE), blob, - Scopes.of(this, containerRef), + Scopes.of(this, ref), authProvider); if (response.statusCode() == 201) { LOG.debug("Successful push: {}", response.response()); diff --git a/src/test/java/land/oras/HarborS3ITCase.java b/src/test/java/land/oras/HarborS3ITCase.java index 4ed8c6c7..e3288ce1 100644 --- a/src/test/java/land/oras/HarborS3ITCase.java +++ b/src/test/java/land/oras/HarborS3ITCase.java @@ -91,7 +91,7 @@ void shouldPushFluxArtifact() { // The compressed manifests Path archive = Paths.get("src/test/resources/archives").resolve("flux-manifests.tgz"); - Path image = Paths.get("src/test/resources/img").resolve("opentofu.png"); + Path image = Paths.get("src/test/resources/img").resolve("flux-cd.png"); String configMediaType = "application/vnd.cncf.flux.config.v1+json"; String contentMediaType = "application/vnd.cncf.flux.content.v1.tar+gzip"; diff --git a/src/test/java/land/oras/OpenTofuITCase.java b/src/test/java/land/oras/OpenTofuITCase.java index b31ae39d..c745897b 100644 --- a/src/test/java/land/oras/OpenTofuITCase.java +++ b/src/test/java/land/oras/OpenTofuITCase.java @@ -56,7 +56,7 @@ void shouldAssembleProviderArtifact() { ArtifactType manifestArtifactType = ArtifactType.from("application/vnd.opentofu.provider-target"); String contentMediaType = "archive/zip"; - Path image = Paths.get("src/test/resources/img").resolve("flux-cd.png"); + Path image = Paths.get("src/test/resources/img").resolve("opentofu.png"); Platform linuxAmd64 = Platform.linuxAmd64(); diff --git a/src/test/resources/archives/terraform-provider-random_3.8.1_linux_amd64.zip b/src/test/resources/archives/terraform-provider-random_3.8.1_linux_amd64.zip new file mode 100644 index 00000000..05b44571 Binary files /dev/null and b/src/test/resources/archives/terraform-provider-random_3.8.1_linux_amd64.zip differ