Skip to content

Commit bc9c4bd

Browse files
authored
Update schema for mediaType validation (#933)
Signed-off-by: Sajay Antony <[email protected]>
1 parent ff02571 commit bc9c4bd

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

image-layout.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Those tags will often be represented in an image-layout repository with matching
162162
```json,title=Image%20Index&mediatype=application/vnd.oci.image.index.v1%2Bjson
163163
{
164164
"schemaVersion": 2,
165+
"mediaType": "application/vnd.oci.image.index.v1+json",
165166
"manifests": [
166167
{
167168
"mediaType": "application/vnd.oci.image.index.v1+json",

schema/image-index-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"minimum": 2,
1212
"maximum": 2
1313
},
14+
"mediaType": {
15+
"description": "the mediatype of the referenced object",
16+
"$ref": "defs-descriptor.json#/definitions/mediaType"
17+
},
1418
"manifests": {
1519
"type": "array",
1620
"items": {

schema/image-manifest-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"minimum": 2,
1212
"maximum": 2
1313
},
14+
"mediaType": {
15+
"description": "the mediatype of the referenced object",
16+
"$ref": "defs-descriptor.json#/definitions/mediaType"
17+
},
1418
"config": {
1519
"$ref": "content-descriptor.json"
1620
},

schema/imageindex_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestImageIndex(t *testing.T) {
3131
imageIndex: `
3232
{
3333
"schemaVersion": 2,
34+
"mediaType": "application/vnd.oci.image.index.v1+json",
3435
"manifests": [
3536
{
3637
"mediaType": "invalid",
@@ -52,6 +53,7 @@ func TestImageIndex(t *testing.T) {
5253
imageIndex: `
5354
{
5455
"schemaVersion": 2,
56+
"mediaType": "application/vnd.oci.image.index.v1+json",
5557
"manifests": [
5658
{
5759
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -73,6 +75,7 @@ func TestImageIndex(t *testing.T) {
7375
imageIndex: `
7476
{
7577
"schemaVersion": 2,
78+
"mediaType": "application/vnd.oci.image.index.v1+json",
7679
"manifests": [
7780
{
7881
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -93,6 +96,7 @@ func TestImageIndex(t *testing.T) {
9396
imageIndex: `
9497
{
9598
"schemaVersion": 2,
99+
"mediaType": "application/vnd.oci.image.index.v1+json",
96100
"manifests": [
97101
{
98102
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -113,6 +117,7 @@ func TestImageIndex(t *testing.T) {
113117
imageIndex: `
114118
{
115119
"schemaVersion": 2,
120+
"mediaType": "application/vnd.oci.image.index.v1+json",
116121
"manifests": [
117122
{
118123
"mediaType": "invalid",
@@ -134,6 +139,7 @@ func TestImageIndex(t *testing.T) {
134139
imageIndex: `
135140
{
136141
"schemaVersion": 2,
142+
"mediaType": "application/vnd.oci.image.index.v1+json",
137143
"manifests": [
138144
{
139145
"mediaType": "",
@@ -155,6 +161,7 @@ func TestImageIndex(t *testing.T) {
155161
imageIndex: `
156162
{
157163
"schemaVersion": 2,
164+
"mediaType": "application/vnd.oci.image.index.v1+json",
158165
"manifests": [
159166
{
160167
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -189,6 +196,7 @@ func TestImageIndex(t *testing.T) {
189196
imageIndex: `
190197
{
191198
"schemaVersion": 2,
199+
"mediaType": "application/vnd.oci.image.index.v1+json",
192200
"manifests": [
193201
{
194202
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@@ -206,6 +214,7 @@ func TestImageIndex(t *testing.T) {
206214
imageIndex: `
207215
{
208216
"schemaVersion": 2,
217+
"mediaType": "application/vnd.oci.image.index.v1+json",
209218
"manifests": [
210219
{
211220
"mediaType": "application/customized.manifest+json",

schema/manifest_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestManifest(t *testing.T) {
3131
manifest: `
3232
{
3333
"schemaVersion": 2,
34+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
3435
"config": {
3536
"mediaType": "invalid",
3637
"size": 1470,
@@ -53,6 +54,8 @@ func TestManifest(t *testing.T) {
5354
manifest: `
5455
{
5556
"schemaVersion": 2,
57+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
58+
"config": {
5659
"config": {
5760
"mediaType": "application/vnd.oci.image.config.v1+json",
5861
"size": "1470",
@@ -75,6 +78,7 @@ func TestManifest(t *testing.T) {
7578
manifest: `
7679
{
7780
"schemaVersion": 2,
81+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
7882
"config": {
7983
"mediaType": "application/vnd.oci.image.config.v1+json",
8084
"size": 1470,
@@ -97,6 +101,7 @@ func TestManifest(t *testing.T) {
97101
manifest: `
98102
{
99103
"schemaVersion": 2,
104+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
100105
"config": {
101106
"mediaType": "application/vnd.oci.image.config.v1+json",
102107
"size": 1470,
@@ -133,6 +138,7 @@ func TestManifest(t *testing.T) {
133138
manifest: `
134139
{
135140
"schemaVersion": 2,
141+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
136142
"config": {
137143
"mediaType": "application/vnd.oci.image.config.v1+json",
138144
"size": 1470,
@@ -165,6 +171,7 @@ func TestManifest(t *testing.T) {
165171
manifest: `
166172
{
167173
"schemaVersion": 2,
174+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
168175
"config": {
169176
"mediaType": "application/vnd.oci.image.config.v1+json",
170177
"size": 1470,
@@ -181,6 +188,7 @@ func TestManifest(t *testing.T) {
181188
manifest: `
182189
{
183190
"schemaVersion": 2,
191+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
184192
"config": {
185193
"mediaType": "application/vnd.oci.image.config.v1+json",
186194
"size": 1470,
@@ -212,6 +220,7 @@ func TestManifest(t *testing.T) {
212220
manifest: `
213221
{
214222
"schemaVersion": 2,
223+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
215224
"config": {
216225
"mediaType": "application/vnd.oci.image.config.v1+json",
217226
"size": 1470,

0 commit comments

Comments
 (0)