content

package
v2.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 63

Documentation

Overview

Package content provides implementations to access content stores.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidDescriptorSize is returned by ReadAll() when
	// the descriptor has an invalid size.
	ErrInvalidDescriptorSize = errors.New("invalid descriptor size")

	// ErrMismatchedDigest is returned by ReadAll() when
	// the descriptor has an invalid digest.
	ErrMismatchedDigest = errors.New("mismatched digest")

	// ErrTrailingData is returned by ReadAll() when
	// there exists trailing data unread when the read terminates.
	ErrTrailingData = errors.New("trailing data")
)

Functions

func Equal

func Equal(a, b ocispec.Descriptor) bool

Equal returns true if two descriptors point to the same content.

func FetchAll

func FetchAll(ctx context.Context, fetcher Fetcher, desc ocispec.Descriptor) ([]byte, error)

FetchAll safely fetches the content described by the descriptor. The fetched content is verified against the size and the digest.

func NewDescriptorFromBytes

func NewDescriptorFromBytes(mediaType string, content []byte) ocispec.Descriptor

NewDescriptorFromBytes returns a descriptor, given the content and media type. If no media type is specified, "application/octet-stream" will be used.

func ReadAll

func ReadAll(r io.Reader, desc ocispec.Descriptor) ([]byte, error)

ReadAll safely reads the content described by the descriptor. The read content is verified against the size and the digest.

func Successors

func Successors(ctx context.Context, fetcher Fetcher, node ocispec.Descriptor) ([]ocispec.Descriptor, error)

Successors returns the nodes directly pointed by the current node. In other words, returns the "children" of the current descriptor.

Types

type Deleter

type Deleter interface {
	// Delete removes the content identified by the descriptor.
	Delete(ctx context.Context, target ocispec.Descriptor) error
}

Deleter removes content. Deleter is an extension of Storage.

type Fetcher

type Fetcher interface {
	// Fetch fetches the content identified by the descriptor.
	Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)
}

Fetcher fetches content.

type FetcherFunc

type FetcherFunc func(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)

FetcherFunc is the basic Fetch method defined in Fetcher.

func (FetcherFunc) Fetch

func (fn FetcherFunc) Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)

Fetch performs Fetch operation by the FetcherFunc.

type GraphStorage

type GraphStorage interface {
	Storage
	PredecessorFinder
}

GraphStorage represents a CAS that supports direct predecessor node finding.

type LimitedStorage

type LimitedStorage struct {
	Storage         // underlying storage
	PushLimit int64 // max size for push
}

LimitedStorage represents a CAS with a push size limit.

func LimitStorage

func LimitStorage(s Storage, n int64) *LimitedStorage

LimitStorage returns a storage with a push size limit.

func (*LimitedStorage) Push

func (ls *LimitedStorage) Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error

Push pushes the content, matching the expected descriptor. The size of the content cannot exceed the push size limit.

type PredecessorFinder

type PredecessorFinder interface {
	// Predecessors returns the nodes directly pointing to the current node.
	Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)
}

PredecessorFinder finds out the nodes directly pointing to a given node of a directed acyclic graph. In other words, returns the "parents" of the current descriptor. PredecessorFinder is an extension of Storage.

type Pusher

type Pusher interface {
	// Push pushes the content, matching the expected descriptor.
	// Reader is perferred to Writer so that the suitable buffer size can be
	// chosen by the underlying implementation. Furthermore, the implementation
	// can also do reflection on the Reader for more advanced I/O optimization.
	Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error
}

Pusher pushes content.

type ReadOnlyGraphStorage

type ReadOnlyGraphStorage interface {
	ReadOnlyStorage
	PredecessorFinder
}

ReadOnlyGraphStorage represents a read-only GraphStorage.

type ReadOnlyStorage

type ReadOnlyStorage interface {
	Fetcher

	// Exists returns true if the described content exists.
	Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)
}

ReadOnlyStorage represents a read-only Storage.

type Resolver

type Resolver interface {
	// Resolve resolves a reference to a descriptor.
	Resolve(ctx context.Context, reference string) (ocispec.Descriptor, error)
}

Resolver resolves reference tags.

type Storage

type Storage interface {
	ReadOnlyStorage
	Pusher
}

Storage represents a content-addressable storage (CAS) where contents are accessed via Descriptors. The storage is designed to handle blobs of large sizes.

type TagResolver

type TagResolver interface {
	Tagger
	Resolver
}

TagResolver provides reference tag indexing services.

type Tagger

type Tagger interface {
	// Tag tags a descriptor with a reference string.
	Tag(ctx context.Context, desc ocispec.Descriptor, reference string) error
}

Tagger tags reference tags.

Directories

Path Synopsis
Package file provides implementation of a content store based on file system.
Package file provides implementation of a content store based on file system.
Package memory provides implementation of a memory backed content store.
Package memory provides implementation of a memory backed content store.
Package oci provides access to an OCI content store.
Package oci provides access to an OCI content store.

Jump to

Keyboard shortcuts

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