ocimem

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ocimem provides a simple in-memory implementation of an OCI registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDescriptor

func CheckDescriptor(desc oci.Descriptor, data []byte) error

CheckDescriptor checks that the given descriptor matches the given data or, if data is nil, that the descriptor looks sane.

func NewBytesReader

func NewBytesReader(data []byte, desc oci.Descriptor) oci.BlobReader

NewBytesReader returns an implementation of oci.BlobReader that returns the given bytes. The returned reader will return desc from its Descriptor method.

Types

type Buffer

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

Buffer holds an in-memory implementation of oci.BlobWriter.

func NewBuffer

func NewBuffer(commit func(b *Buffer) error, uuid string) *Buffer

NewBuffer returns a buffer that calls commit with the when Buffer.Commit is invoked successfully. / It's OK to call methods concurrently on a buffer.

func (*Buffer) Cancel

func (b *Buffer) Cancel() error

Cancel cancels the blob upload and frees associated resources.

func (*Buffer) ChunkSize

func (b *Buffer) ChunkSize() int

ChunkSize returns the maximum number of bytes to upload at a single time.

func (*Buffer) Close

func (b *Buffer) Close() error

Close closes the writer but does not abort the upload.

func (*Buffer) Commit

func (b *Buffer) Commit(dig oci.Digest) (_ oci.Descriptor, err error)

Commit implements oci.BlobWriter.Commit by checking that everything looks OK and calling the commit function if so.

func (*Buffer) GetBlob

func (b *Buffer) GetBlob() (oci.Descriptor, []byte, error)

GetBlob returns any committed data and is descriptor. It returns an error if the data hasn't been committed or there was an error doing so.

func (*Buffer) ID

func (b *Buffer) ID() string

ID implements oci.BlobWriter.ID by returning a randomly allocated hex UUID.

func (*Buffer) Size

func (b *Buffer) Size() int64

Size returns the number of bytes written to this buffer so far.

func (*Buffer) Write

func (b *Buffer) Write(data []byte) (int, error)

Write implements io.Writer by writing some data to the blob.

type Config

type Config struct {
	// ImmutableTags specifies that tags in the registry cannot
	// be changed. Specifically the following restrictions are enforced:
	// - no removal of tags from a manifest
	// - no pushing of a tag if that tag already exists with a different
	// digest or media type.
	// - no deletion of directly tagged manifests
	// - no deletion of any blob or manifest that a tagged manifest
	// refers to (TODO: not implemented yet)
	ImmutableTags bool

	// LaxChildReferences causes the usual child reference checks made
	// by ocimem to be skipped. This includes references to blobs by
	// manifests and by manifests (indexes) to other manifests, but not
	// subject references, because the spec defines those to be always
	// lax.
	LaxChildReferences bool
}

Config holds configuration for the registry.

type Registry

type Registry struct {
	*oci.Funcs
	// contains filtered or unexported fields
}

Registry is an in-memory implementation of oci.Interface.

func New

func New() *Registry

New is like NewWithConfig(nil).

func NewWithConfig

func NewWithConfig(cfg0 *Config) *Registry

NewWithConfig returns a new in-memory oci.Interface implementation using the given configuration. If cfg is nil, it's treated the same as a pointer to the zero Config value.

func (*Registry) DeleteBlob

func (r *Registry) DeleteBlob(ctx context.Context, repoName string, digest oci.Digest) error

DeleteBlob deletes the blob with the given digest from the named repository.

func (*Registry) DeleteManifest

func (r *Registry) DeleteManifest(ctx context.Context, repoName string, digest oci.Digest) error

DeleteManifest deletes the manifest with the given digest from the named repository.

func (*Registry) DeleteTag

func (r *Registry) DeleteTag(ctx context.Context, repoName string, tagName string) error

DeleteTag deletes the given tag from the named repository.

func (*Registry) GetBlob

func (r *Registry) GetBlob(ctx context.Context, repoName string, dig oci.Digest) (oci.BlobReader, error)

GetBlob returns the content of the blob with the given digest.

func (*Registry) GetBlobRange

func (r *Registry) GetBlobRange(ctx context.Context, repoName string, dig oci.Digest, o0, o1 int64) (oci.BlobReader, error)

GetBlobRange returns a range of bytes from the blob with the given digest.

func (*Registry) GetManifest

func (r *Registry) GetManifest(ctx context.Context, repoName string, dig oci.Digest) (oci.BlobReader, error)

GetManifest returns the content of the manifest with the given digest.

func (*Registry) GetTag

func (r *Registry) GetTag(ctx context.Context, repoName string, tagName string) (oci.BlobReader, error)

GetTag returns the content of the manifest with the given tag.

func (*Registry) MountBlob

func (r *Registry) MountBlob(ctx context.Context, fromRepo, toRepo string, dig oci.Digest) (oci.Descriptor, error)

MountBlob makes a blob from one repository available in another.

func (*Registry) PushBlob

func (r *Registry) PushBlob(ctx context.Context, repoName string, desc oci.Descriptor, content io.Reader) (oci.Descriptor, error)

PushBlob pushes a blob to the named repository.

func (*Registry) PushBlobChunked

func (r *Registry) PushBlobChunked(ctx context.Context, repoName string, chunkSize int) (oci.BlobWriter, error)

PushBlobChunked starts a chunked blob upload to the named repository.

func (*Registry) PushBlobChunkedResume

func (r *Registry) PushBlobChunkedResume(ctx context.Context, repoName, id string, offset int64, chunkSize int) (oci.BlobWriter, error)

PushBlobChunkedResume resumes a previously started chunked blob upload.

func (*Registry) PushManifest

func (r *Registry) PushManifest(ctx context.Context, repoName string, data []byte, mediaType string, params *oci.PushManifestParameters) (oci.Descriptor, error)

PushManifest pushes a manifest to the named repository, optionally tagging it.

func (*Registry) Referrers

func (r *Registry) Referrers(_ context.Context, repoName string, digest oci.Digest, params *oci.ReferrersParameters) iter.Seq2[oci.Descriptor, error]

Referrers returns an iterator over descriptors that refer to the given digest.

func (*Registry) Repositories

func (r *Registry) Repositories(_ context.Context, startAfter string) iter.Seq2[string, error]

Repositories returns an iterator over all repository names in the registry.

func (*Registry) ResolveBlob

func (r *Registry) ResolveBlob(ctx context.Context, repoName string, digest oci.Digest) (oci.Descriptor, error)

ResolveBlob returns the descriptor for the blob with the given digest.

func (*Registry) ResolveManifest

func (r *Registry) ResolveManifest(ctx context.Context, repoName string, digest oci.Digest) (oci.Descriptor, error)

ResolveManifest returns the descriptor for the manifest with the given digest.

func (*Registry) ResolveTag

func (r *Registry) ResolveTag(ctx context.Context, repoName string, tagName string) (oci.Descriptor, error)

ResolveTag returns the descriptor for the manifest with the given tag.

func (*Registry) Tags

func (r *Registry) Tags(_ context.Context, repoName string, params *oci.TagsParameters) iter.Seq2[string, error]

Tags returns an iterator over tags in the named repository.

Jump to

Keyboard shortcuts

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