Documentation ¶
Overview ¶
Package types contains various data types and well known constants.
Index ¶
- Constants
- Variables
- func ErrRespJSON(w io.Writer, errList ...ErrorInfo) error
- func ManifestReferrerDescriptor(raw []byte, d Descriptor) (Descriptor, Descriptor, error)
- func MediaTypeAccepts(mt string, accepts []string) bool
- func MediaTypeBase(orig string) string
- func MediaTypeDetect(raw []byte) string
- func MediaTypeForeign(mt string) bool
- func MediaTypeImage(mt string) bool
- func MediaTypeIndex(mt string) bool
- type BytesReadCloser
- type Descriptor
- type ErrorInfo
- func ErrInfoBlobUnknown(d string) ErrorInfo
- func ErrInfoBlobUploadInvalid(d string) ErrorInfo
- func ErrInfoBlobUploadUnknown(d string) ErrorInfo
- func ErrInfoDenied(d string) ErrorInfo
- func ErrInfoDigestInvalid(d string) ErrorInfo
- func ErrInfoManifestBlobUnknown(d string) ErrorInfo
- func ErrInfoManifestInvalid(d string) ErrorInfo
- func ErrInfoManifestUnknown(d string) ErrorInfo
- func ErrInfoNameInvalid(d string) ErrorInfo
- func ErrInfoNameUnknown(d string) ErrorInfo
- func ErrInfoSizeInvalid(d string) ErrorInfo
- func ErrInfoTooManyRequests(d string) ErrorInfo
- func ErrInfoUnauthorized(d string) ErrorInfo
- func ErrInfoUnsupported(d string) ErrorInfo
- type ErrorResp
- type Index
- type IndexOpt
- type Layout
- type Manifest
- type Platform
- type TagList
Constants ¶
const ( // AnnotRefName is the annotation key for the tag, set on a descriptor in the OCI Layout index.json. AnnotRefName = "org.opencontainers.image.ref.name" // AnnotReferrerSubject is used on descriptors that point to the referrer response in an OCI layout index.json. // The value is the digest of the subject. AnnotReferrerSubject = "org.olareg.referrer.subject" // AnnotReferrerConvert is set to true to indicate any referrers in the OCI Layout pushed with the fallback tag have been converted to the referrer.subject annotation. AnnotReferrerConvert = "org.olareg.referrer.convert" )
const ( // MediaTypeDockerPrefix is used to identify Docker media types. MediaTypeDockerPrefix = "application/vnd.docker." // MediaTypeDocker2Manifest is the media type when pulling manifests from a v2 registry. MediaTypeDocker2Manifest = "application/vnd.docker.distribution.manifest.v2+json" // MediaTypeDocker2ManifestList is the media type when pulling a manifest list from a v2 registry. MediaTypeDocker2ManifestList = "application/vnd.docker.distribution.manifest.list.v2+json" // MediaTypeDocker2ImageConfig is for the configuration json object media type. MediaTypeDocker2ImageConfig = "application/vnd.docker.container.image.v1+json" // MediaTypeOCIPrefix is used to identify OCI media types. MediaTypeOCIPrefix = "application/vnd.oci." // MediaTypeOCI1Manifest OCI v1 manifest media type. MediaTypeOCI1Manifest = "application/vnd.oci.image.manifest.v1+json" // MediaTypeOCI1ManifestList OCI v1 manifest list media type. MediaTypeOCI1ManifestList = "application/vnd.oci.image.index.v1+json" // MediaTypeOCI1ImageConfig OCI v1 configuration json object media type. MediaTypeOCI1ImageConfig = "application/vnd.oci.image.config.v1+json" // MediaTypeOCI1Layer is the uncompressed layer for OCIv1. MediaTypeOCI1Layer = "application/vnd.oci.image.layer.v1.tar" // MediaTypeOCI1LayerGzip is the gzip compressed layer for OCI v1. MediaTypeOCI1LayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip" // MediaTypeDocker2ForeignLayer is the default compressed layer for foreign layers in docker schema2. MediaTypeDocker2ForeignLayer = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip" // MediaTypeOCI1ForeignLayer is the foreign layer for OCI v1. MediaTypeOCI1ForeignLayer = "application/vnd.oci.image.layer.nondistributable.v1.tar" // MediaTypeOCI1ForeignLayerGzip is the gzip compressed foreign layer for OCI v1. MediaTypeOCI1ForeignLayerGzip = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip" // MediaTypeOCI1ForeignLayerZstd is the zstd compressed foreign layer for OCI v1. MediaTypeOCI1ForeignLayerZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd" // MediaTypeOCI1Empty is used for blobs containing the empty JSON data `{}`. MediaTypeOCI1Empty = "application/vnd.oci.empty.v1+json" )
const (
HeaderDockerDigest = "Docker-Content-Digest"
)
const (
// LayoutVersion is the supported release of the OCI Layout file definition.
LayoutVersion = "1.0.0"
)
Variables ¶
var ( // ErrBlobExists is returned when attempting to create a blob that already exists. ErrBlobExists = errors.New("blob exists") // ErrNotFound is returned when a resource is not found. ErrNotFound = errors.New("not found") // ErrReadOnly is returned when the storage system does not permit write access. ErrReadOnly = errors.New("read only storage") // ErrRepoNotAllowed is used when a repository name is not permitted. ErrRepoNotAllowed = errors.New("repository name is not permitted") )
var ( // RefTagRE is a regexp for a valid tag. RefTagRE = regexp.MustCompile(`^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$`) )
Functions ¶
func ErrRespJSON ¶
ErrRespJSON encodes a list of errors to json and outputs them to the writer.
func ManifestReferrerDescriptor ¶
func ManifestReferrerDescriptor(raw []byte, d Descriptor) (Descriptor, Descriptor, error)
ManifestReferrerDescriptor parses a manifest to generate the descriptor used in the referrer response. Two descriptors are returned, the subject, and the entry for the referrers response. The descriptor should be provided with a valid MediaType and Digest, otherwise they will be generated as a best effort.
func MediaTypeAccepts ¶
MediaTypeAccepts returns true when the descriptor is listed in the accept list.
func MediaTypeBase ¶
MediaTypeBase cleans the Content-Type header to return only the lower case base media type.
func MediaTypeDetect ¶
MediaTypeDetect determines the most likely media type for a raw manifest. The returned string is empty if detection fails.
func MediaTypeForeign ¶
MediaTypeForeign returns true if the media type is a known foreign layer value.
func MediaTypeImage ¶
MediaTypeImage returns true if the media type is an Image Manifest.
func MediaTypeIndex ¶
MediaTypeIndex returns true if the media type is an Index/ManifestList.
Types ¶
type BytesReadCloser ¶
BytesReadCloser wraps a bytes.Reader to make it an io.ReadSeekCloser
type Descriptor ¶
type Descriptor struct { // MediaType describe the type of the content. MediaType string `json:"mediaType"` // Digest uniquely identifies the content. Digest digest.Digest `json:"digest"` // Size in bytes of content. Size int64 `json:"size"` // URLs contains the source URLs of this content. URLs []string `json:"urls,omitempty"` // Annotations contains arbitrary metadata relating to the targeted content. Annotations map[string]string `json:"annotations,omitempty"` // Data is an embedding of the targeted content. This is encoded as a base64 // string when marshalled to JSON (automatically, by encoding/json). If // present, Data can be used directly to avoid fetching the targeted content. Data []byte `json:"data,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"` // ArtifactType is the media type of the artifact this descriptor refers to. ArtifactType string `json:"artifactType,omitempty"` }
Descriptor is used in manifests to refer to content by media type, size, and digest.
func (Descriptor) Copy ¶
func (d Descriptor) Copy() Descriptor
Copy returns a copy of the descriptor
type ErrorInfo ¶
type ErrorInfo struct { Code string `json:"code"` Message string `json:"message"` Detail string `json:"detail"` }
ErrorInfo describes an error entry from ErrorResp.
func ErrInfoBlobUnknown ¶
ErrInfoBlobUnknown is returned when the blob unknown to the registry.
func ErrInfoBlobUploadInvalid ¶
ErrInfoBlobUploadInvalid is returned when the blob upload is invalid.
func ErrInfoBlobUploadUnknown ¶
ErrInfoBlobUploadUnknown is returned when the blob upload is unknown to registry.
func ErrInfoDenied ¶
ErrInfoDenied is returned when the requested access to the resource is denied.
func ErrInfoDigestInvalid ¶
ErrInfoDigestInvalid is returned when the provided digest did not match the uploaded content.
func ErrInfoManifestBlobUnknown ¶
ErrInfoManifestBlobUnknown is returned when the manifest references a manifest or blob unknown to the registry.
func ErrInfoManifestInvalid ¶
ErrInfoManifestInvalid is returned when the manifest is invalid.
func ErrInfoManifestUnknown ¶
ErrInfoManifestUnknown is returned when the manifest unknown to the registry.
func ErrInfoNameInvalid ¶
ErrInfoNameInvalid is returned when the repository name is invalid.
func ErrInfoNameUnknown ¶
ErrInfoNameUnknown is returned when the repository name is not known to the registry.
func ErrInfoSizeInvalid ¶
ErrInfoSizeInvalid is returned when provided length did not match the content length.
func ErrInfoTooManyRequests ¶
ErrInfoTooManyRequests is returned when there are too many requests.
func ErrInfoUnauthorized ¶
ErrInfoUnauthorized is returned when authentication is required.
func ErrInfoUnsupported ¶
ErrInfoUnsupported is returned when the operation is unsupported.
type ErrorResp ¶
type ErrorResp struct {
Errors []ErrorInfo `json:"errors"`
}
ErrorResp is returned by the registry on an invalid request.
type Index ¶
type Index struct { // SchemaVersion is the image manifest schema that this image follows SchemaVersion int `json:"schemaVersion"` // MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json` MediaType string `json:"mediaType,omitempty"` // ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact. ArtifactType string `json:"artifactType,omitempty"` // Manifests references platform specific manifests. Manifests []Descriptor `json:"manifests"` // Subject is an optional link from the image manifest to another manifest forming an association between the image manifest and the other manifest. Subject *Descriptor `json:"subject,omitempty"` // Annotations contains arbitrary metadata for the image index. Annotations map[string]string `json:"annotations,omitempty"` // contains filtered or unexported fields }
Index references manifests for various platforms.
func (*Index) AddChildren ¶
func (i *Index) AddChildren(children []Descriptor)
AddChildren is used by store implementations to track descriptors from nested manifests (in a child index).
func (*Index) AddDesc ¶
func (i *Index) AddDesc(d Descriptor, opts ...IndexOpt)
AddDesc adds an entry to the Index with deduplication. Alternate references to a tag or referrers response are removed. If a descriptor exists but a tag or referrer annotation is being added, an existing descriptor will be updated. If the descriptor exists as a child, it is removed from the child entries. This method ignores and may lose unrecognized fields and annotations. The "WithChildren" option moves matching descriptors without annotations to child manifest list.
func (*Index) GetByAnnotation ¶
func (i *Index) GetByAnnotation(key, val string) (Descriptor, error)
GetByAnnotation finds an entry with a matching annotation.
func (Index) GetDesc ¶
func (i Index) GetDesc(arg string) (Descriptor, error)
GetDesc returns a descriptor for a tag or digest, including child descriptors.
func (*Index) RmDesc ¶
func (i *Index) RmDesc(d Descriptor)
RmDesc deletes a descriptor from the index. If the descriptor has a digest and the tag value set, one reference to the untagged digest is preserved. If the digest is blank and either tag or referrer annotations are provided, all matching tags/referrers are deleted. Otherwise all references to the digest are removed.
type IndexOpt ¶
type IndexOpt func(*indexConf)
func IndexWithChildren ¶
func IndexWithChildren(children []Descriptor) IndexOpt
IndexWithChildren is used by Index.AddDesc to specify child descriptors to move from Manifest to childManifest descriptor list.
type Layout ¶
type Layout struct { // Version is the implemented OCI Layout version in a given directory. Version string `json:"imageLayoutVersion"` }
Layout is the JSON contents of the oci-layout file.
type Manifest ¶
type Manifest struct { // SchemaVersion is the image manifest schema that this image follows SchemaVersion int `json:"schemaVersion"` // MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json` MediaType string `json:"mediaType,omitempty"` // ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact. ArtifactType string `json:"artifactType,omitempty"` // Config references a configuration object for a container, by digest. // The referenced configuration object is a JSON blob that the runtime uses to set up the container. Config Descriptor `json:"config"` // Layers is an indexed list of layers referenced by the manifest. Layers []Descriptor `json:"layers"` // Subject is an optional link from the image manifest to another manifest forming an association between the image manifest and the other manifest. Subject *Descriptor `json:"subject,omitempty"` // Annotations contains arbitrary metadata for the image manifest. Annotations map[string]string `json:"annotations,omitempty"` }
Manifest defines an OCI image
type Platform ¶
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 `10.0.10586`. 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 `ppc64le` to specify a little-endian version of a PowerPC CPU. Variant string `json:"variant,omitempty"` // Features is an optional field specifying an array of strings, each listing a required CPU feature (for example `sse4` or `aes`). Features []string `json:"features,omitempty"` }
Platform specifies a platform where a particular image manifest is applicable.