content

package
v0.0.0-...-13f90e9 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(cw Writer, r io.Reader, size int64, expected digest.Digest) error

Copy copies data with the expected digest from the reader into the provided content store writer.

This is useful when the digest and size are known beforehand. When the size or digest is unknown, these values may be empty.

Copy is buffered, so no need to wrap reader in buffered io.

func ReadBlob

func ReadBlob(ctx context.Context, provider Provider, dgst digest.Digest) ([]byte, error)

ReadBlob retrieves the entire contents of the blob from the provider.

Avoid using this for large blobs, such as layers.

func WriteBlob

func WriteBlob(ctx context.Context, cs Ingester, ref string, r io.Reader, size int64, expected digest.Digest) error

WriteBlob writes data with the expected digest into the content store. If expected already exists, the method returns immediately and the reader will not be consumed.

This is useful when the digest and size are known beforehand.

Copy is buffered, so no need to wrap reader in buffered io.

Types

type Info

type Info struct {
	Digest      digest.Digest
	Size        int64
	CommittedAt time.Time
}

TODO(stevvooe): Consider a very different name for this struct. Info is way to general. It also reads very weird in certain context, like pluralization.

type Ingester

type Ingester interface {
	Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error)
}

type Manager

type Manager interface {
	// Info will return metadata about content available in the content store.
	//
	// If the content is not present, ErrNotFound will be returned.
	Info(ctx context.Context, dgst digest.Digest) (Info, error)

	// Walk will call fn for each item in the content store.
	Walk(ctx context.Context, fn WalkFunc) error

	// Delete removes the content from the store.
	Delete(ctx context.Context, dgst digest.Digest) error

	// Status returns the status of any active ingestions whose ref match the
	// provided regular expression. If empty, all active ingestions will be
	// returned.
	//
	// TODO(stevvooe): Status may be slighly out of place here. If this remains
	// here, we should remove Manager and just define these on store.
	Status(ctx context.Context, re string) ([]Status, error)

	// Abort completely cancels the ingest operation targeted by ref.
	//
	// TODO(stevvooe): Same consideration as above. This should really be
	// restricted to an ingest management interface.
	Abort(ctx context.Context, ref string) error
}

Manager provides methods for inspecting, listing and removing content.

type Provider

type Provider interface {
	Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error)
	ReaderAt(ctx context.Context, dgst digest.Digest) (io.ReaderAt, error)
}

type Status

type Status struct {
	Ref       string
	Offset    int64
	Total     int64
	Expected  digest.Digest
	StartedAt time.Time
	UpdatedAt time.Time
}

type Store

type Store interface {
	Manager
	Ingester
	Provider
}

Store combines the methods of content-oriented interfaces into a set that are commonly provided by complete implementations.

func NewStore

func NewStore(root string) (Store, error)

type WalkFunc

type WalkFunc func(Info) error

WalkFunc defines the callback for a blob walk.

type Writer

type Writer interface {
	io.WriteCloser
	Status() (Status, error)
	Digest() digest.Digest
	Commit(size int64, expected digest.Digest) error
	Truncate(size int64) error
}

Jump to

Keyboard shortcuts

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