Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/notaryproject/artifacts

go 1.16

require github.com/opencontainers/go-digest v1.0.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
97 changes: 97 additions & 0 deletions schema/image-index-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"description": "OpenContainer Image Index Specification",
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://opencontainers.org/schema/image/index",
"type": "object",
"properties": {
"schemaVersion": {
"description": "This field specifies the image index schema version as an integer",
"id": "https://opencontainers.org/schema/image/index/schemaVersion",
"type": "integer",
"minimum": 2,
"maximum": 2
},
"mediaType": {
"description": "the mediatype of the referenced object",
"$ref": "defs-descriptor.json#/definitions/mediaType"
},
"config": {
"$ref": "https://opencontainers.org/schema/descriptor"
},
"manifests": {
"type": "array",
"items": {
"id": "https://opencontainers.org/schema/image/manifestDescriptor",
"type": "object",
"required": [
"mediaType",
"size",
"digest"
],
"properties": {
"mediaType": {
"description": "the mediatype of the referenced object",
"$ref": "defs-descriptor.json#/definitions/mediaType"
},
"size": {
"description": "the size in bytes of the referenced object",
"$ref": "defs.json#/definitions/int64"
},
"digest": {
"description": "the cryptographic checksum digest of the object, in the pattern '<algorithm>:<encoded>'",
"$ref": "defs-descriptor.json#/definitions/digest"
},
"urls": {
"description": "a list of urls from which this object may be downloaded",
"$ref": "defs-descriptor.json#/definitions/urls"
},
"platform": {
"id": "https://opencontainers.org/schema/image/platform",
"type": "object",
"required": [
"architecture",
"os"
],
"properties": {
"architecture": {
"id": "https://opencontainers.org/schema/image/platform/architecture",
"type": "string"
},
"os": {
"id": "https://opencontainers.org/schema/image/platform/os",
"type": "string"
},
"os.version": {
"id": "https://opencontainers.org/schema/image/platform/os.version",
"type": "string"
},
"os.features": {
"id": "https://opencontainers.org/schema/image/platform/os.features",
"type": "array",
"items": {
"type": "string"
}
},
"variant": {
"type": "string"
}
}
},
"annotations": {
"id": "https://opencontainers.org/schema/image/descriptor/annotations",
"$ref": "defs-descriptor.json#/definitions/annotations"
}
}
}
},
"annotations": {
"id": "https://opencontainers.org/schema/image/index/annotations",
"$ref": "defs-descriptor.json#/definitions/annotations"
}
},
"required": [
"schemaVersion",
"config",
"manifests"
]
}
27 changes: 27 additions & 0 deletions specs-go/v2/artifact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package v2

import "github.com/notaryproject/artifacts/specs-go"

// Artifact describes a registry artifact.
// This structure provides `application/vnd.oci.artifact.manifest.v1+json` mediatype when marshalled to JSON.
type Artifact struct {
specs.Versioned

// MediaType is the media type of the object this schema refers to.
MediaType string `json:"mediaType"`

// ArtifactType is the artifact type of the object this schema refers to.
ArtifactType string `json:"artifactType"`

// Config references the configuration of the object this schema refers to. It is optional.
Config *Descriptor `json:"config,omitempty"`

// Blobs is a collection of blobs referenced by this manifest.
Blobs []Descriptor `json:"blobs"`

// Manifests is a collection of manifests this artifact is linked to.
Manifests []Descriptor `json:"manifests"`

// Annotations contains arbitrary metadata for the artifact manifest.
Annotations map[string]string `json:"annotations,omitempty"`
}
6 changes: 6 additions & 0 deletions specs-go/v2/artifacttype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package v2

const (
// ArtifactTypeNotaryV2 specifies the artifact type for a notary V2 object.
ArtifactTypeNotaryV2 = "application/vnd.cncf.notary.v2"
)
64 changes: 64 additions & 0 deletions specs-go/v2/descriptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2016 The Linux Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v2

import digest "github.com/opencontainers/go-digest"

// Descriptor describes the disposition of targeted content.
// This structure provides `application/vnd.oci.descriptor.v1+json` mediatype
// when marshalled to JSON.
type Descriptor struct {
// MediaType is the media type of the object this schema refers to.
MediaType string `json:"mediaType,omitempty"`

// Digest is the digest of the targeted content.
Digest digest.Digest `json:"digest"`

// Size specifies the size in bytes of the blob.
Size int64 `json:"size"`

// URLs specifies a list of URLs from which this object MAY be downloaded
URLs []string `json:"urls,omitempty"`

// Annotations contains arbitrary metadata relating to the targeted content.
Annotations map[string]string `json:"annotations,omitempty"`

// Platform describes the platform which the image in the manifest runs on.
//
// This should only be used when referring to a manifest.
Platform *Platform `json:"platform,omitempty"`
}

// Platform describes the platform which the image in the manifest runs on.
type Platform struct {
// Architecture field specifies the CPU architecture, for example
// `amd64` or `ppc64`.
Architecture string `json:"architecture"`

// OS specifies the operating system, for example `linux` or `windows`.
OS string `json:"os"`

// OSVersion is an optional field specifying the operating system
// version, for example on Windows `10.0.14393.1066`.
OSVersion string `json:"os.version,omitempty"`

// OSFeatures is an optional field specifying an array of strings,
// each listing a required OS feature (for example on Windows `win32k`).
OSFeatures []string `json:"os.features,omitempty"`

// Variant is an optional field specifying a variant of the CPU, for
// example `v7` to specify ARMv7 when architecture is `arm`.
Variant string `json:"variant,omitempty"`
}
6 changes: 6 additions & 0 deletions specs-go/v2/mediatype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package v2

const (
// MediaTypeArtifactManifest specifies the media type for an OCI artifact.
MediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json"
)
9 changes: 9 additions & 0 deletions specs-go/versioned.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package specs

// Versioned provides a struct with the manifest schemaVersion and mediaType.
// Incoming content with unknown schema version can be decoded against this
// struct to check the version.
type Versioned struct {
// SchemaVersion is the image manifest schema that this image follows
SchemaVersion int `json:"schemaVersion"`
}