Documentation
¶
Overview ¶
Package oci implemens utilities for interacting with Open Container Initiative image reference, annotations, distribution (registry) APIs and more. SEE: https://github.com/opencontainers/distribution-spec/blob/main/spec.md SEE: https://github.com/opencontainers/image-spec/blob/main/annotations.md SEE: https://github.com/opencontainers/image-spec/blob/main/spec.md SEE: https://github.com/distribution/reference SEE: https://github.com/opencontainers/artifacts
Index ¶
- Constants
- func ErrorIsResourceUnknown(err error) bool
- func ManifestsMaybeEqual(a any, b any, platform *Platform) bool
- func NameFromAPI(path string) string
- type APIError
- type APIErrorCode
- type Annotations
- type Blob
- type BlobInfo
- type Client
- func (c *Client) GetAnnotations(ctx context.Context, ref Reference, options *GetAnnotationsOptions) (Annotations, error)
- func (c *Client) GetBlob(ctx context.Context, ref Reference, digest string, cache bool) (Blob, error)
- func (c *Client) GetManifest(ctx context.Context, ref Reference) (any, error)
- func (c *Client) GetManifestBlob(ctx context.Context, ref Reference) (Blob, error)
- func (c *Client) GetTags(ctx context.Context, image Reference, options *GetTagsOptions) ([]string, error)
- func (c *Client) HeadBlob(ctx context.Context, ref Reference, digest string) (*BlobInfo, error)
- type GetAnnotationsOptions
- type GetTagsOptions
- type ImageIndex
- type ImageManifest
- type Platform
- type Reference
Constants ¶
const ( // APIErrorCodeBlobUnknown is returned when a blob is unknown to the // registry. APIErrorCodeBlobUnknown = "BLOB_UNKNOWN" // APIErrorCodeBlobUploadInvalid is returned when a blob upload is // invalid. APIErrorCodeBlobUploadInvalid = "BLOB_UPLOAD_INVALID" // APIErrorCodeBlobUploadUnknown is returned when a blob upload is // unknown to the registry. APIErrorCodeBlobUploadUnknown = "BLOB_UPLOAD_UNKNOWN" // APIErrorCodeDigestInvalid is returned when a provided digest did // not match uploaded content. APIErrorCodeDigestInvalid = "DIGEST_INVALID" // APIErrorCodeManifestBlobUnknwon is returned when a manifest // references a manifest or blob that is unknown to the registry. APIErrorCodeManifestBlobUnknwon = "MANIFEST_BLOB_UNKNOWN" // APIErrorCodeManifestInvalid is returned when a manifest is // invalid. APIErrorCodeManifestInvalid = "MANIFEST_INVALID" // APIErrorCodeManifestUnknown is returned when a manifest is unknown // to the registry. APIErrorCodeManifestUnknown = "MANIFEST_UNKNOWN" // APIErrorCodeNameInvalid is returned when an invalid repository // name is used. APIErrorCodeNameInvalid = "NAME_INVALID" // APIErrorCodeNameUnknown is returned when a repository name is not // known to registry. APIErrorCodeNameUnknown = "NAME_UNKNOWN" // APIErrorCodeSizeInvalid is returned when a provided length did not // match content length. APIErrorCodeSizeInvalid = "SIZE_INVALID" APIErrorCodeUnauthorized = "UNAUTHORIZED" // APIErrorCodeDenied is returned when the requested access to the // resource is denied. APIErrorCodeDenied = "DENIED" // APIErrorCodeUnsupported is returned when the operation is // unsupported. APIErrorCodeUnsupported = "UNSUPPORTED" // APIErrorCodeTooManyRequests is returned when the client has sent // too many requests. APIErrorCodeTooManyRequests = "TOOMANYREQUESTS" )
Variables ¶
This section is empty.
Functions ¶
func ErrorIsResourceUnknown ¶ added in v0.16.0
ErrorIsResourceUnknown returns true if the error is an APIError which points at the error being that the resource (blob, manifest, name) us unknown to the registry.
func ManifestsMaybeEqual ¶ added in v0.16.0
ManifestsMaybeEqual returns true if the manifests may be equal when resolved on the (optionally) specified platform.
func NameFromAPI ¶ added in v0.16.0
NameFromAPI returns the OCI name based on the distribution spec API endpoint. Assumes name has at least two components. SEE: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#endpoints
Types ¶
type APIError ¶ added in v0.16.0
type APIError struct { Status string StatusCode int Code APIErrorCode Message string Detail string }
type APIErrorCode ¶ added in v0.16.0
type APIErrorCode string
type Annotations ¶
func (Annotations) CreatedTime ¶ added in v0.13.0
func (a Annotations) CreatedTime() time.Time
func (Annotations) DocumentationURL ¶ added in v0.13.0
func (a Annotations) DocumentationURL() string
func (Annotations) Merge ¶ added in v0.16.0
func (a Annotations) Merge(b Annotations) Annotations
Merge returns the merge of a and b. If both are nil, nil is returned.
func (Annotations) Source ¶
func (a Annotations) Source() string
func (Annotations) URL ¶ added in v0.13.0
func (a Annotations) URL() string
type BlobInfo ¶ added in v0.16.0
type BlobInfo struct { // ContentType is the blob's content type. ContentType string // ContentLength is the size of the blob as reported by the server, if // reported at all. SHOULD be reported by all servers. ContentLength int64 // Digest is the digest of the blob as reported by the server, if reported at // all. SHOULD be reported by all servers. If it is reported MUST match the // blob's actual digest. Digest string }
type Client ¶
func (*Client) GetAnnotations ¶
func (c *Client) GetAnnotations(ctx context.Context, ref Reference, options *GetAnnotationsOptions) (Annotations, error)
GetAnnotations tries to identify annotations for the reference. Fetches manifests as necessary. To narrow down the search and to avoid unnecessary fetches, specify the available options.
func (*Client) GetBlob ¶
func (c *Client) GetBlob(ctx context.Context, ref Reference, digest string, cache bool) (Blob, error)
GetBlob downloads a blob from an OCI registry. SEE: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-blobs
func (*Client) GetManifest ¶
GetManifest downloads a [Manifest] or a [ManifestIndex] from an OCI registry. SEE: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull
func (*Client) GetManifestBlob ¶ added in v0.16.0
GetManifestBlob downloads a manifest from an OCI registry. SEE: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull
type GetAnnotationsOptions ¶
type GetAnnotationsOptions struct { Manifests []ImageManifest Digest string Architecture string OS string Variant string }
type GetTagsOptions ¶
type ImageIndex ¶ added in v0.16.0
type ImageIndex struct { ContentType string SchemaVersion int MediaType string Manifests []ImageManifest Digest string Annotations Annotations }
type ImageManifest ¶ added in v0.16.0
type Reference ¶
type Reference struct { Domain string Path string HasTag bool Tag string HasDigest bool Digest string }
func ParseReference ¶
func (Reference) MarshalJSON ¶
func (Reference) Reference ¶ added in v0.16.0
Reference returns the reference as used by OCI distribution APIs.
func (*Reference) UnmarshalJSON ¶
func (Reference) Version ¶
Version is the familiar version of the reference, such as its tag, digest or "latest", if no tag or digest is specified. Mostly useful for human-readable use cases. For use with APIs, see Reference.Reference.