oci

package
v1.0.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArtifactTypeMessage = "application/vnd.dockercomms.message.v1"
	ArtifactTypeReceipt = "application/vnd.dockercomms.receipt.v1"
	ArtifactTypeBundle  = "application/vnd.dev.sigstore.bundle.v0.3+json"

	MediaTypeManifest     = ocispec.MediaTypeImageManifest
	MediaTypeChunkGzip    = "application/vnd.dockercomms.chunk.v1.tar+gzip"
	MediaTypeChunkZstd    = "application/vnd.dockercomms.chunk.v1.tar+zstd"
	MediaTypeEmptyConfig  = "application/vnd.oci.empty.v1+json"
	MediaTypeBundleConfig = ArtifactTypeBundle
)

Artifact and media types per SPEC.md.

Variables

View Source
var EmptyConfigDescriptor = ocispec.Descriptor{
	MediaType: MediaTypeEmptyConfig,
	Digest:    digest.Digest("sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"),
	Size:      2,
}

Empty config descriptor per spec (J).

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps oras-go remote repository for OCI operations.

func NewClient

func NewClient(reference string) (*Client, error)

NewClient creates an OCI client for the given registry/repo reference. Reference format: registry/repo (e.g. ghcr.io/user/repo).

func (*Client) EnsureEmptyConfig

func (c *Client) EnsureEmptyConfig(ctx context.Context) error

EnsureEmptyConfig pushes the canonical empty config blob if not present.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, desc ocispec.Descriptor) (bool, error)

Exists returns true if the blob exists in the repository.

func (*Client) FetchBlob

func (c *Client) FetchBlob(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error)

FetchBlob downloads a blob.

func (*Client) FetchManifest

func (c *Client) FetchManifest(ctx context.Context, reference string) (ocispec.Descriptor, io.ReadCloser, error)

FetchManifest fetches manifest by tag or digest.

func (*Client) PushBlob

func (c *Client) PushBlob(ctx context.Context, desc ocispec.Descriptor, content io.Reader) error

PushBlob uploads a blob. Skips if Exists returns true (caller responsibility for resume).

func (*Client) PushManifest

func (c *Client) PushManifest(ctx context.Context, desc ocispec.Descriptor, content io.Reader, tag string) error

PushManifest pushes a manifest and tags it.

func (*Client) Referrers

func (c *Client) Referrers(ctx context.Context, subject ocispec.Descriptor, artifactType string, fn func([]ocispec.Descriptor) error) error

Referrers lists referrers for the given subject. artifactType filters by type (empty = all).

func (*Client) ReferrersSupported

func (c *Client) ReferrersSupported(ctx context.Context, subject ocispec.Descriptor) bool

ReferrersSupported returns true if the registry supports the Referrers API. Best-effort: attempts a referrers call with a valid digest; on 404/unsupported returns false.

func (*Client) Resolve

func (c *Client) Resolve(ctx context.Context, reference string) (ocispec.Descriptor, error)

Resolve resolves a tag or digest to a manifest descriptor.

func (*Client) Tag

func (c *Client) Tag(ctx context.Context, desc ocispec.Descriptor, tag string) error

Tag tags an existing manifest.

func (*Client) Tags

func (c *Client) Tags(ctx context.Context, last string, fn func(tags []string) error) error

Tags lists tags with pagination. fn is called for each page.

type ManifestBuilder

type ManifestBuilder struct {
	ArtifactType string
	Subject      *ocispec.Descriptor
	Annotations  map[string]string
	Layers       []ocispec.Descriptor
}

ManifestBuilder builds OCI manifest with DockerComms annotations.

func NewBundleManifest

func NewBundleManifest(subject ocispec.Descriptor, bundleAnnotations map[string]string, layer ocispec.Descriptor) *ManifestBuilder

NewBundleManifest creates a manifest builder for a bundle artifact with subject for referrers.

func NewMessageManifest

func NewMessageManifest(annotations map[string]string, layers []ocispec.Descriptor) *ManifestBuilder

NewMessageManifest creates a manifest builder for a message artifact.

func NewReceiptManifest

func NewReceiptManifest(annotations map[string]string) *ManifestBuilder

NewReceiptManifest creates a manifest builder for a receipt artifact.

func (*ManifestBuilder) Build

func (b *ManifestBuilder) Build() ([]byte, ocispec.Descriptor, error)

Build produces the OCI manifest JSON and descriptor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL