Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Commit 1e21ca3

Browse files
authored
add go specs for artifact manifest (#17)
* add go specs for artifact manifest * update mediaType * define artifact descriptor * remove dependency on opencontainers/image-spec by referencing the artifact-descriptor Signed-off-by: Aviral Takkar <[email protected]>
1 parent f11b467 commit 1e21ca3

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/oras-project/artifacts-spec
2+
3+
go 1.17
4+
5+
require github.com/opencontainers/go-digest v1.0.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
2+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=

specs-go/v1/descriptor.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2021 ORAS Authors.
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 v1
16+
17+
import digest "github.com/opencontainers/go-digest"
18+
19+
// Descriptor describes the disposition of targeted content.
20+
type Descriptor struct {
21+
// MediaType is the media type of the object this schema refers to.
22+
MediaType string `json:"mediaType,omitempty"`
23+
24+
// ArtifactType is the artifact type of the object this schema refers to.
25+
//
26+
// When the descriptor is used for blobs, this property must be empty.
27+
ArtifactType string `json:"artifactType"`
28+
29+
// Digest is the digest of the targeted content.
30+
Digest digest.Digest `json:"digest"`
31+
32+
// Size specifies the size in bytes of the blob.
33+
Size int64 `json:"size"`
34+
35+
// URLs specifies a list of URLs from which this object MAY be downloaded
36+
URLs []string `json:"urls,omitempty"`
37+
38+
// Annotations contains arbitrary metadata relating to the targeted content.
39+
Annotations map[string]string `json:"annotations,omitempty"`
40+
}

specs-go/v1/manifest.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2021 ORAS Authors.
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 v1
16+
17+
// Manifest describes an ORAS artifact.
18+
// This structure provides `application/vnd.oras.artifact.manifest.v1+json` mediatype when marshalled to JSON.
19+
type Manifest struct {
20+
// MediaType is the media type of the object this schema refers to.
21+
MediaType string `json:"mediaType"`
22+
23+
// ArtifactType is the artifact type of the object this schema refers to.
24+
ArtifactType string `json:"artifactType"`
25+
26+
// Blobs is a collection of blobs referenced by this manifest.
27+
Blobs []Descriptor `json:"blobs"`
28+
29+
// SubjectManifest is an optional reference to any existing manifest within the repository.
30+
// When specified, the artifact is said to be dependent upon the referenced subjectManifest.
31+
SubjectManifest Descriptor `json:"subjectManifest"`
32+
33+
// Annotations contains arbitrary metadata for the artifact manifest.
34+
Annotations map[string]string `json:"annotations,omitempty"`
35+
}

specs-go/v1/mediatype.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2021 ORAS Authors.
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 v1
16+
17+
const (
18+
// MediaTypeArtifactManifest specifies the media type for an ORAS artifact reference type manifest.
19+
MediaTypeArtifactManifest = "application/vnd.cncf.oras.artifact.manifest.v1+json"
20+
)

0 commit comments

Comments
 (0)