ocimem

package
v0.0.0-...-eedc705 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 3

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 ociregistry.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 ociregistry.Descriptor) ociregistry.BlobReader

NewBytesReader returns an implementation of ociregistry.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 ociregistry.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

func (*Buffer) ChunkSize

func (b *Buffer) ChunkSize() int

func (*Buffer) Close

func (b *Buffer) Close() error

func (*Buffer) Commit

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

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

func (*Buffer) GetBlob

func (b *Buffer) GetBlob() (ociregistry.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 ociregistry.BlobWriter.ID by returning a randomly allocated hex UUID.

func (*Buffer) Size

func (b *Buffer) Size() int64

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
}

Config holds configuration for the registry.

type Registry

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

func New

func New() *Registry

New is like NewWithConfig(nil).

func NewWithConfig

func NewWithConfig(cfg0 *Config) *Registry

NewWithConfig returns a new in-memory ociregistry.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 ociregistry.Digest) error

func (*Registry) DeleteManifest

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

func (*Registry) DeleteTag

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

func (*Registry) GetBlob

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

func (*Registry) GetBlobRange

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

func (*Registry) GetManifest

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

func (*Registry) GetTag

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

func (*Registry) MountBlob

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

func (*Registry) PushBlob

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

func (*Registry) PushBlobChunked

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

func (*Registry) PushBlobChunkedResume

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

func (*Registry) PushManifest

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

func (*Registry) Referrers

func (r *Registry) Referrers(ctx context.Context, repoName string, digest ociregistry.Digest, artifactType string) ociregistry.Seq[ociregistry.Descriptor]

func (*Registry) Repositories

func (r *Registry) Repositories(ctx context.Context, startAfter string) ociregistry.Seq[string]

func (*Registry) ResolveBlob

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

func (*Registry) ResolveManifest

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

func (*Registry) ResolveTag

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

func (*Registry) Tags

func (r *Registry) Tags(ctx context.Context, repoName string, startAfter string) ociregistry.Seq[string]

Jump to

Keyboard shortcuts

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