diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/BuildableManifestTemplate.java b/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/BuildableManifestTemplate.java index c61ff881df..1be6029cf2 100644 --- a/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/BuildableManifestTemplate.java +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/BuildableManifestTemplate.java @@ -42,7 +42,6 @@ public interface BuildableManifestTemplate extends ManifestTemplate { */ class ContentDescriptorTemplate implements JsonTemplate { - @SuppressWarnings("unused") @Nullable private String mediaType; @@ -61,6 +60,11 @@ class ContentDescriptorTemplate implements JsonTemplate { @SuppressWarnings("unused") protected ContentDescriptorTemplate() {} + @Nullable + public String getMediaType() { + return mediaType; + } + public long getSize() { return size; } diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/OciManifestTemplateTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/OciManifestTemplateTest.java index 6eaac9c4bf..e448aa9c04 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/OciManifestTemplateTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/OciManifestTemplateTest.java @@ -71,11 +71,15 @@ public void testFromJson() throws IOException, URISyntaxException, DigestExcepti Assert.assertEquals(1000, manifestJson.getContainerConfiguration().getSize()); + BuildableManifestTemplate.ContentDescriptorTemplate layer = manifestJson.getLayers().get(0); + Assert.assertEquals( DescriptorDigest.fromHash( "4945ba5011739b0b98c4a41afe224e417f47c7c99b2ce76830999c9a0861b236"), - manifestJson.getLayers().get(0).getDigest()); + layer.getDigest()); + + Assert.assertEquals(1000_000, layer.getSize()); - Assert.assertEquals(1000_000, manifestJson.getLayers().get(0).getSize()); + Assert.assertEquals("application/vnd.oci.image.manifest.v1+json", layer.getMediaType()); } } diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/V22ManifestTemplateTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/V22ManifestTemplateTest.java index 91955bc901..439c432b43 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/V22ManifestTemplateTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/image/json/V22ManifestTemplateTest.java @@ -75,12 +75,16 @@ public void testFromJson() throws IOException, URISyntaxException, DigestExcepti Assert.assertEquals(1000, manifestJson.getContainerConfiguration().getSize()); + ContentDescriptorTemplate layer = manifestJson.getLayers().get(0); + Assert.assertEquals( DescriptorDigest.fromHash( "4945ba5011739b0b98c4a41afe224e417f47c7c99b2ce76830999c9a0861b236"), - manifestJson.getLayers().get(0).getDigest()); + layer.getDigest()); + + Assert.assertEquals(1000_000, layer.getSize()); - Assert.assertEquals(1000_000, manifestJson.getLayers().get(0).getSize()); + Assert.assertEquals("application/vnd.docker.image.rootfs.diff.tar.gzip", layer.getMediaType()); } @Test diff --git a/jib-core/src/test/resources/core/json/v22manifest_optional_properties.json b/jib-core/src/test/resources/core/json/v22manifest_optional_properties.json index 19b2a0e914..93da5bcf81 100644 --- a/jib-core/src/test/resources/core/json/v22manifest_optional_properties.json +++ b/jib-core/src/test/resources/core/json/v22manifest_optional_properties.json @@ -30,6 +30,11 @@ "size": 4, "urls": ["cool-url"], "annotations": {"key1":"value1", "key2":"value2"} + }, + { + "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", + "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 5 } ] } \ No newline at end of file