Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 9d10a67

Browse files
authored
Merge pull request #2 from aviral26/prototype-1
Merging to enable notaryproject/distribution (prototype-1) to reference types. Add index v2 specs-go and schema
2 parents ecce2ed + 9ddc965 commit 9d10a67

4 files changed

Lines changed: 212 additions & 0 deletions

File tree

schema/image-index-schema.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"description": "OpenContainer Image Index Specification",
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"id": "https://opencontainers.org/schema/image/index",
5+
"type": "object",
6+
"properties": {
7+
"schemaVersion": {
8+
"description": "This field specifies the image index schema version as an integer",
9+
"id": "https://opencontainers.org/schema/image/index/schemaVersion",
10+
"type": "integer",
11+
"minimum": 2,
12+
"maximum": 2
13+
},
14+
"mediaType": {
15+
"description": "the mediatype of the referenced object",
16+
"$ref": "defs-descriptor.json#/definitions/mediaType"
17+
},
18+
"config": {
19+
"$ref": "https://opencontainers.org/schema/descriptor"
20+
},
21+
"manifests": {
22+
"type": "array",
23+
"items": {
24+
"id": "https://opencontainers.org/schema/image/manifestDescriptor",
25+
"type": "object",
26+
"required": [
27+
"mediaType",
28+
"size",
29+
"digest"
30+
],
31+
"properties": {
32+
"mediaType": {
33+
"description": "the mediatype of the referenced object",
34+
"$ref": "defs-descriptor.json#/definitions/mediaType"
35+
},
36+
"size": {
37+
"description": "the size in bytes of the referenced object",
38+
"$ref": "defs.json#/definitions/int64"
39+
},
40+
"digest": {
41+
"description": "the cryptographic checksum digest of the object, in the pattern '<algorithm>:<encoded>'",
42+
"$ref": "defs-descriptor.json#/definitions/digest"
43+
},
44+
"urls": {
45+
"description": "a list of urls from which this object may be downloaded",
46+
"$ref": "defs-descriptor.json#/definitions/urls"
47+
},
48+
"platform": {
49+
"id": "https://opencontainers.org/schema/image/platform",
50+
"type": "object",
51+
"required": [
52+
"architecture",
53+
"os"
54+
],
55+
"properties": {
56+
"architecture": {
57+
"id": "https://opencontainers.org/schema/image/platform/architecture",
58+
"type": "string"
59+
},
60+
"os": {
61+
"id": "https://opencontainers.org/schema/image/platform/os",
62+
"type": "string"
63+
},
64+
"os.version": {
65+
"id": "https://opencontainers.org/schema/image/platform/os.version",
66+
"type": "string"
67+
},
68+
"os.features": {
69+
"id": "https://opencontainers.org/schema/image/platform/os.features",
70+
"type": "array",
71+
"items": {
72+
"type": "string"
73+
}
74+
},
75+
"variant": {
76+
"type": "string"
77+
}
78+
}
79+
},
80+
"annotations": {
81+
"id": "https://opencontainers.org/schema/image/descriptor/annotations",
82+
"$ref": "defs-descriptor.json#/definitions/annotations"
83+
}
84+
}
85+
}
86+
},
87+
"annotations": {
88+
"id": "https://opencontainers.org/schema/image/index/annotations",
89+
"$ref": "defs-descriptor.json#/definitions/annotations"
90+
}
91+
},
92+
"required": [
93+
"schemaVersion",
94+
"config",
95+
"manifests"
96+
]
97+
}

specs-go/v2/descriptor.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v2
16+
17+
import digest "github.com/opencontainers/go-digest"
18+
19+
// Descriptor describes the disposition of targeted content.
20+
// This structure provides `application/vnd.oci.descriptor.v1+json` mediatype
21+
// when marshalled to JSON.
22+
type Descriptor struct {
23+
// MediaType is the media type of the object this schema refers to.
24+
MediaType string `json:"mediaType,omitempty"`
25+
26+
// Digest is the digest of the targeted content.
27+
Digest digest.Digest `json:"digest"`
28+
29+
// Size specifies the size in bytes of the blob.
30+
Size int64 `json:"size"`
31+
32+
// URLs specifies a list of URLs from which this object MAY be downloaded
33+
URLs []string `json:"urls,omitempty"`
34+
35+
// Annotations contains arbitrary metadata relating to the targeted content.
36+
Annotations map[string]string `json:"annotations,omitempty"`
37+
38+
// Platform describes the platform which the image in the manifest runs on.
39+
//
40+
// This should only be used when referring to a manifest.
41+
Platform *Platform `json:"platform,omitempty"`
42+
}
43+
44+
// Platform describes the platform which the image in the manifest runs on.
45+
type Platform struct {
46+
// Architecture field specifies the CPU architecture, for example
47+
// `amd64` or `ppc64`.
48+
Architecture string `json:"architecture"`
49+
50+
// OS specifies the operating system, for example `linux` or `windows`.
51+
OS string `json:"os"`
52+
53+
// OSVersion is an optional field specifying the operating system
54+
// version, for example on Windows `10.0.14393.1066`.
55+
OSVersion string `json:"os.version,omitempty"`
56+
57+
// OSFeatures is an optional field specifying an array of strings,
58+
// each listing a required OS feature (for example on Windows `win32k`).
59+
OSFeatures []string `json:"os.features,omitempty"`
60+
61+
// Variant is an optional field specifying a variant of the CPU, for
62+
// example `v7` to specify ARMv7 when architecture is `arm`.
63+
Variant string `json:"variant,omitempty"`
64+
}

specs-go/v2/index.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v2
16+
17+
// Index references manifests for various platforms.
18+
// This structure provides `application/vnd.oci.image.index.v2+json` mediatype when marshalled to JSON.
19+
type Index struct {
20+
// MediaType is the media type of the object this schema refers to.
21+
MediaType string `json:"mediaType,omitempty"`
22+
23+
// Config references the index configuration.
24+
Config Descriptor `json:"config,omitempty"`
25+
26+
// Manifests references platform specific manifests.
27+
Manifests []Descriptor `json:"manifests"`
28+
29+
// Annotations contains arbitrary metadata for the image index.
30+
Annotations map[string]string `json:"annotations,omitempty"`
31+
}

specs-go/v2/mediatype.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v2
16+
17+
const (
18+
// MediaTypeImageIndex specifies the media type for an image index.
19+
MediaTypeImageIndex = "application/vnd.oci.image.index.v2+json"
20+
)

0 commit comments

Comments
 (0)