Skip to content

Commit

Permalink
Merge pull request opencontainers#1021 from vbatts/fix_manifest_schema
Browse files Browse the repository at this point in the history
manifest schema: add the missing `subject` field
  • Loading branch information
vbatts authored Feb 13, 2023
2 parents 1cd112b + 31de013 commit 2e644ce
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions schema/image-manifest-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"config": {
"$ref": "content-descriptor.json"
},
"subject": {
"$ref": "content-descriptor.json"
},
"layers": {
"type": "array",
"minItems": 1,
Expand Down
52 changes: 52 additions & 0 deletions schema/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,58 @@ func TestManifest(t *testing.T) {
`,
},

// expected success: subject field with a valid descriptor
{
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"subject" : {
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 1234,
"digest": "sha256:220a60ecd4a3c32c282622a625a54db9ba0ff55b5ba9c29c7064a2bc358b6a3e"
},
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
"digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b"
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"size": 1470,
"digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b"
}
]
}
`,
fail: false,
},

// expected failure: subject field with invalid value (something that is not a descriptor)
{
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"subject" : ".nope",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
"digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b"
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"size": 1470,
"digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b"
}
]
}
`,
fail: true,
},

// expected failure: push bounds of algorithm field in digest too far.
{
manifest: `
Expand Down

0 comments on commit 2e644ce

Please sign in to comment.