Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public List<String> getDigestsForPlatform(String architecture, String os) {
* href="https://github.com/opencontainers/image-spec/blob/main/image-index.md">OCI Image Index
* Specification</a>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public static class ManifestDescriptorTemplate
extends BuildableManifestTemplate.ContentDescriptorTemplate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public List<String> getDigestsForPlatform(String architecture, String os) {
}

/** Template for inner JSON object representing a single platform specific manifest. */
@JsonIgnoreProperties(ignoreUnknown = true)
public static class ManifestDescriptorTemplate implements JsonTemplate {

@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ public void testFromJson() throws IOException, URISyntaxException, DigestExcepti
Assert.assertEquals(1000, manifest.getSize());
}

@Test
public void testFromJsonWithUnknownProperties()
throws IOException, URISyntaxException, DigestException {
// Loads a JSON index whose manifest descriptors carry an OCI 1.1 "artifactType" field, which
// Jib does not model. Unknown descriptor properties must be ignored rather than fail parsing.
// https://github.com/GoogleContainerTools/jib/issues/4506
Path jsonFile =
Paths.get(Resources.getResource("core/json/ociindex_artifacttype.json").toURI());

OciIndexTemplate ociIndexJson =
JsonTemplateMapper.readJsonFromFile(jsonFile, OciIndexTemplate.class);

Assert.assertEquals(2, ociIndexJson.getManifests().size());
Assert.assertEquals(
"sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f",
ociIndexJson.getDigestsForPlatform("amd64", "linux").get(0));
Assert.assertEquals(
"sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270",
ociIndexJson.getDigestsForPlatform("arm64", "linux").get(0));
}

@Test
public void testToJsonWithPlatform() throws DigestException, IOException, URISyntaxException {
// Loads the expected JSON string.
Expand Down
26 changes: 26 additions & 0 deletions jib-core/src/test/resources/core/json/ociindex_artifacttype.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1395,
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f",
"platform": {
"architecture": "amd64",
"os": "linux"
},
"artifactType": "application/vnd.docker.container.image.v1+json"
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1395,
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270",
"platform": {
"architecture": "arm64",
"os": "linux"
},
"artifactType": "application/vnd.docker.container.image.v1+json"
}
]
}
3 changes: 2 additions & 1 deletion jib-core/src/test/resources/core/json/v22manifest_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"platform": {
"architecture": "ppc64le",
"os": "linux"
}
},
"artifactType": "application/vnd.docker.container.image.v1+json"
},
{
"mediaType": "application/vnd.docker.image.manifest.v2+json",
Expand Down