Documentation
¶
Index ¶
- Variables
- func WithStorage(fetcher content.Fetcher, pusher content.Pusher) func(*Blob)
- type Artifact
- func (a *Artifact) Annotations() map[string]string
- func (a *Artifact) ArtifactType(ctx context.Context) (string, error)
- func (a *Artifact) Blobs(ctx context.Context) ([]*Blob, error)
- func (a *Artifact) Descriptor() ocispec.Descriptor
- func (a *Artifact) Digest() digest.Digest
- func (a *Artifact) Load(ctx context.Context) error
- func (a *Artifact) MarshalJSON() ([]byte, error)
- func (a *Artifact) MediaType() string
- func (a *Artifact) Predecessors(ctx context.Context) ([]Manifest, error)
- func (a *Artifact) Push(ctx context.Context, reference string) error
- func (a *Artifact) SetSubject(subject Manifest)
- func (a *Artifact) Size() int64
- func (a *Artifact) Subject(ctx context.Context) (Manifest, error)
- type Blob
- func (b *Blob) Annotations() map[string]string
- func (b *Blob) Bytes(ctx context.Context) ([]byte, error)
- func (b *Blob) Delete(ctx context.Context) error
- func (b *Blob) Descriptor() ocispec.Descriptor
- func (b *Blob) Digest() digest.Digest
- func (b *Blob) MediaType() string
- func (b *Blob) Push(ctx context.Context) error
- func (b *Blob) Read(ctx context.Context) (io.ReadCloser, error)
- func (b *Blob) Size() int64
- func (b *Blob) Verify(ctx context.Context) error
- func (b *Blob) WithAnnotation(key, value string) *Blob
- type Content
- type Image
- func (i *Image) Annotations() map[string]string
- func (i *Image) Config(ctx context.Context) (*Blob, error)
- func (i *Image) Descriptor() ocispec.Descriptor
- func (i *Image) Digest() digest.Digest
- func (i *Image) Layers(ctx context.Context) ([]*Blob, error)
- func (i *Image) Load(ctx context.Context) error
- func (i *Image) MarshalJSON() ([]byte, error)
- func (i *Image) MediaType() string
- func (i *Image) Platform(ctx context.Context) (*ocispec.Platform, error)
- func (i *Image) Predecessors(ctx context.Context) ([]Manifest, error)
- func (i *Image) Push(ctx context.Context, reference string) error
- func (i *Image) SetSubject(subject Manifest)
- func (i *Image) Size() int64
- func (i *Image) Subject(ctx context.Context) (Manifest, error)
- type Index
- func (idx *Index) Annotations() map[string]string
- func (idx *Index) Descriptor() ocispec.Descriptor
- func (idx *Index) Digest() digest.Digest
- func (idx *Index) FilterByPlatform(ctx context.Context, target *ocispec.Platform) ([]Manifest, error)
- func (idx *Index) Load(ctx context.Context) error
- func (idx *Index) Manifests(ctx context.Context) ([]Manifest, error)
- func (idx *Index) MarshalJSON() ([]byte, error)
- func (idx *Index) MediaType() string
- func (idx *Index) Predecessors(ctx context.Context) ([]Manifest, error)
- func (idx *Index) Push(ctx context.Context, reference string) error
- func (idx *Index) SetSubject(subject Manifest)
- func (idx *Index) Size() int64
- func (idx *Index) Subject(ctx context.Context) (Manifest, error)
- type Manifest
- type ManifestClient
- type ObjectsError
- type Reference
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoFetcher indicates that no fetcher was provided for content retrieval. ErrNoFetcher = errors.New("no fetcher provided") // ErrNoPusher indicates that no pusher was provided for content storage. ErrNoPusher = errors.New("no pusher provided") // ErrNoContent indicates that no content is available. ErrNoContent = errors.New("no content available") // ErrInvalidManifest indicates that the manifest is invalid or malformed. ErrInvalidManifest = errors.New("invalid manifest") // ErrNoClient indicates that no client was provided. ErrNoClient = errors.New("no client provided") // ErrNotLoaded indicates that the manifest has not been loaded yet. // Call Load(ctx) or any method that accepts a context to load the manifest // before serializing. ErrNotLoaded = errors.New("manifest not loaded: call Load(ctx) first") // ErrNoDeleter indicates that the target does not support deletion. ErrNoDeleter = errors.New("target does not support deletion") )
Functions ¶
Types ¶
type Artifact ¶
type Artifact struct {
// contains filtered or unexported fields
}
Artifact represents an OCI artifact manifest. Artifacts contain typed blobs and can reference a subject manifest.
func NewArtifact ¶
func NewArtifact(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient) *Artifact
NewArtifact creates a new Artifact from a descriptor.
func NewArtifactFromManifestBytes ¶
func NewArtifactFromManifestBytes(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient, manifestBytes []byte) (*Artifact, error)
NewArtifactFromManifestBytes creates a new Artifact with a pre-loaded manifest. This avoids a redundant network fetch when the manifest bytes are already available (e.g., from type detection).
func (*Artifact) Annotations ¶
Annotations returns a copy of the annotations associated with this artifact. If the manifest is already loaded, annotations are read from the manifest body (where they are authoritative). Otherwise the descriptor annotations are used as a fallback. The returned map is safe to modify.
func (*Artifact) ArtifactType ¶
ArtifactType returns the artifact type (IANA media type).
func (*Artifact) Blobs ¶
Blobs returns all blobs referenced by this artifact. The blobs are lazily loaded and cached.
func (*Artifact) Descriptor ¶
func (a *Artifact) Descriptor() ocispec.Descriptor
Descriptor returns the OCI descriptor for this artifact.
func (*Artifact) MarshalJSON ¶
MarshalJSON marshals the artifact manifest to JSON. The manifest must have been loaded first via Load(ctx) or any method that accepts a context. Returns ErrNotLoaded if not yet loaded.
func (*Artifact) Predecessors ¶
Predecessors returns all manifests that reference this artifact.
func (*Artifact) SetSubject ¶
SetSubject sets the subject manifest for this artifact.
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob represents a binary content object (layer, config, arbitrary data). Blobs are immutable and content-addressable.
func NewBlob ¶
NewBlob creates a new Blob from a descriptor. The content is not loaded until accessed via Read() or Bytes().
func NewBlobFromBytes ¶
NewBlobFromBytes creates a new Blob from raw bytes. The descriptor is computed from the content. Optional fetcher and pusher can be provided for storage operations.
func (*Blob) Annotations ¶
Annotations returns a copy of the annotations associated with this blob. The returned map is safe to modify without affecting the blob.
func (*Blob) Bytes ¶
Bytes returns the blob content as a byte slice. The content is lazily loaded and cached for subsequent calls. On transient errors, the result is NOT cached, allowing retry. Use Read() for streaming large blobs to avoid memory pressure.
func (*Blob) Delete ¶
Delete removes this blob from storage. The pusher must implement content.Deleter.
func (*Blob) Descriptor ¶
func (b *Blob) Descriptor() ocispec.Descriptor
Descriptor returns the OCI descriptor for this blob.
func (*Blob) Read ¶
Read returns a ReadCloser for streaming the blob content. This is useful for large blobs that should not be loaded entirely into memory. The returned reader verifies the content digest on read. Call VerifyReader.Verify() after reading to confirm integrity, or use Bytes() which verifies automatically.
func (*Blob) Verify ¶
Verify fetches the content and verifies it matches the descriptor's digest and size. This is useful for checking integrity without retaining the content in memory.
func (*Blob) WithAnnotation ¶
WithAnnotation returns a new Blob with the given annotation added. The original blob is not modified.
type Content ¶
type Content interface {
// Descriptor returns the OCI descriptor for this content.
Descriptor() ocispec.Descriptor
// Digest returns the digest of the content.
Digest() digest.Digest
// MediaType returns the media type of the content.
MediaType() string
// Size returns the size of the content in bytes.
Size() int64
// Annotations returns the annotations associated with this content.
Annotations() map[string]string
}
Content represents any OCI content that can be stored and retrieved. This is the base interface for all ORM models (Blob, Artifact, Image, Index).
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an OCI or Docker image manifest. Images have a config and layers, and may support platform specification.
func NewImage ¶
func NewImage(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient) *Image
NewImage creates a new Image from a descriptor.
func NewImageFromManifestBytes ¶
func NewImageFromManifestBytes(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient, manifestBytes []byte) (*Image, error)
NewImageFromManifestBytes creates a new Image with a pre-loaded manifest. This avoids a redundant network fetch when the manifest bytes are already available (e.g., from type detection).
func (*Image) Annotations ¶
Annotations returns a copy of the annotations associated with this image. If the manifest is already loaded, annotations are read from the manifest body (where they are authoritative). Otherwise the descriptor annotations are used as a fallback. The returned map is safe to modify.
func (*Image) Config ¶
Config returns the config blob for this image. The config is lazily loaded and cached.
func (*Image) Descriptor ¶
func (i *Image) Descriptor() ocispec.Descriptor
Descriptor returns the OCI descriptor for this image.
func (*Image) Layers ¶
Layers returns all layer blobs for this image. The layers are lazily loaded and cached.
func (*Image) MarshalJSON ¶
MarshalJSON marshals the image manifest to JSON. The manifest must have been loaded first via Load(ctx) or any method that accepts a context. Returns ErrNotLoaded if not yet loaded.
func (*Image) Platform ¶
Platform returns the platform specification for this image. Returns nil if no platform is specified.
func (*Image) Predecessors ¶
Predecessors returns all manifests that reference this image.
func (*Image) SetSubject ¶
SetSubject sets the subject manifest for this image.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index represents an OCI image index (manifest list). Indexes contain multiple manifests, typically for different platforms.
func NewIndex ¶
func NewIndex(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient) *Index
NewIndex creates a new Index from a descriptor.
func NewIndexFromManifestBytes ¶
func NewIndexFromManifestBytes(desc ocispec.Descriptor, fetcher content.Fetcher, pusher content.Pusher, client ManifestClient, indexBytes []byte) (*Index, error)
NewIndexFromManifestBytes creates a new Index with a pre-loaded manifest. This avoids a redundant network fetch when the manifest bytes are already available (e.g., from type detection).
func (*Index) Annotations ¶
Annotations returns a copy of the annotations associated with this index. If the index manifest is already loaded, annotations are read from the manifest body (where they are authoritative). Otherwise the descriptor annotations are used as a fallback. The returned map is safe to modify.
func (*Index) Descriptor ¶
func (idx *Index) Descriptor() ocispec.Descriptor
Descriptor returns the OCI descriptor for this index.
func (*Index) FilterByPlatform ¶
func (idx *Index) FilterByPlatform(ctx context.Context, target *ocispec.Platform) ([]Manifest, error)
FilterByPlatform returns manifests matching the given platform. Uses the library's internal/platform.Match which handles Architecture, OS, Variant, OSVersion, and OSFeatures comparison.
func (*Index) Manifests ¶
Manifests returns all manifests in this index. The manifests are lazily loaded and cached.
func (*Index) MarshalJSON ¶
MarshalJSON marshals the index to JSON. The index must have been loaded first via Load(ctx) or any method that accepts a context. Returns ErrNotLoaded if not yet loaded.
func (*Index) Predecessors ¶
Predecessors returns all manifests that reference this index.
func (*Index) SetSubject ¶
SetSubject sets the subject manifest for this index.
type Manifest ¶
type Manifest interface {
Content
// Load eagerly loads the manifest data from storage.
// This must be called before MarshalJSON if the manifest was created
// from a descriptor (lazy loading).
Load(ctx context.Context) error
// Subject returns the subject (parent) manifest this manifest refers to.
// Returns nil if no subject is set.
Subject(ctx context.Context) (Manifest, error)
// SetSubject sets the subject (parent) manifest for this manifest.
SetSubject(subject Manifest)
// Predecessors returns all manifests that reference this manifest.
// This is useful for finding referrers (signatures, SBOMs, etc.).
Predecessors(ctx context.Context) ([]Manifest, error)
// Push pushes this manifest to the target with the given reference.
Push(ctx context.Context, reference string) error
}
Manifest represents content that is a manifest (Artifact, Image, or Index). Manifests can reference other content and have subjects.
type ManifestClient ¶
type ManifestClient interface {
// FetchManifest fetches a manifest by descriptor.
FetchManifest(ctx context.Context, desc ocispec.Descriptor) (Manifest, error)
// FetchByReference fetches a manifest by reference (tag or digest string).
FetchByReference(ctx context.Context, reference string) (Manifest, error)
// FindPredecessors finds all manifests that reference the given content.
FindPredecessors(ctx context.Context, content Content) ([]Manifest, error)
// PushManifest pushes a manifest with a reference.
PushManifest(ctx context.Context, manifest Manifest, reference string) error
}
ManifestClient provides operations for manifest relationships.
type ObjectsError ¶
type ObjectsError struct {
Op string // Operation that failed (e.g., "load", "fetch_blobs").
Digest digest.Digest // Digest of the content involved, if known.
Err error // Underlying error.
}
ObjectsError provides structured error context for objects operations.
func (*ObjectsError) Error ¶
func (e *ObjectsError) Error() string
func (*ObjectsError) Unwrap ¶
func (e *ObjectsError) Unwrap() error
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference represents a named reference to a manifest (tag or other reference). Reference is safe for concurrent use.
func NewReference ¶
func NewReference(name string, manifest Manifest, client ManifestClient) *Reference
NewReference creates a new Reference. If manifest is non-nil, it is pre-cached (Resolve will return it immediately).
func (*Reference) Manifest ¶
Manifest returns the cached manifest if already resolved. Returns (manifest, true) if resolved, or (nil, false) if not yet resolved.