Skip to content

Commit

Permalink
Update schema for mediaType validation (#933)
Browse files Browse the repository at this point in the history
Signed-off-by: Sajay Antony <sajaya@microsoft.com>
  • Loading branch information
sajayantony committed Aug 25, 2022
1 parent ff02571 commit bc9c4bd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions image-layout.md
Expand Up @@ -162,6 +162,7 @@ Those tags will often be represented in an image-layout repository with matching
```json,title=Image%20Index&mediatype=application/vnd.oci.image.index.v1%2Bjson
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
Expand Down
4 changes: 4 additions & 0 deletions schema/image-index-schema.json
Expand Up @@ -11,6 +11,10 @@
"minimum": 2,
"maximum": 2
},
"mediaType": {
"description": "the mediatype of the referenced object",
"$ref": "defs-descriptor.json#/definitions/mediaType"
},
"manifests": {
"type": "array",
"items": {
Expand Down
4 changes: 4 additions & 0 deletions schema/image-manifest-schema.json
Expand Up @@ -11,6 +11,10 @@
"minimum": 2,
"maximum": 2
},
"mediaType": {
"description": "the mediatype of the referenced object",
"$ref": "defs-descriptor.json#/definitions/mediaType"
},
"config": {
"$ref": "content-descriptor.json"
},
Expand Down
9 changes: 9 additions & 0 deletions schema/imageindex_test.go
Expand Up @@ -31,6 +31,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "invalid",
Expand All @@ -52,6 +53,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
Expand All @@ -73,6 +75,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
Expand All @@ -93,6 +96,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
Expand All @@ -113,6 +117,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "invalid",
Expand All @@ -134,6 +139,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "",
Expand All @@ -155,6 +161,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
Expand Down Expand Up @@ -189,6 +196,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
Expand All @@ -206,6 +214,7 @@ func TestImageIndex(t *testing.T) {
imageIndex: `
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/customized.manifest+json",
Expand Down
9 changes: 9 additions & 0 deletions schema/manifest_test.go
Expand Up @@ -31,6 +31,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "invalid",
"size": 1470,
Expand All @@ -53,6 +54,8 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": "1470",
Expand All @@ -75,6 +78,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand All @@ -97,6 +101,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand Down Expand Up @@ -133,6 +138,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand Down Expand Up @@ -165,6 +171,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand All @@ -181,6 +188,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand Down Expand Up @@ -212,6 +220,7 @@ func TestManifest(t *testing.T) {
manifest: `
{
"schemaVersion": 2,
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 1470,
Expand Down

0 comments on commit bc9c4bd

Please sign in to comment.