content

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(ctx context.Context, cw Writer, r io.Reader, size int64, expected digest.Digest, opts ...Opt) error

Copy copies data with the expected digest from the reader into the provided content store writer. This copy commits the 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 CopyReaderAt

func CopyReaderAt(cw Writer, ra ReaderAt, n int64) error

CopyReaderAt copies to a writer from a given reader at for the given number of bytes. This copy does not commit the writer.

func NewReader

func NewReader(ra ReaderAt) io.Reader

NewReader returns a io.Reader from a ReaderAt

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, opts ...Opt) 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
	CreatedAt time.Time
	UpdatedAt time.Time
	Labels    map[string]string
}

Info holds content specific information

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 IngestManager

type IngestManager interface {
	// Status returns the status of the provided ref.
	Status(ctx context.Context, ref string) (Status, error)

	// ListStatuses returns the status of any active ingestions whose ref match the
	// provided regular expression. If empty, all active ingestions will be
	// returned.
	ListStatuses(ctx context.Context, filters ...string) ([]Status, error)

	// Abort completely cancels the ingest operation targeted by ref.
	Abort(ctx context.Context, ref string) error
}

IngestManager provides methods for managing ingests.

type Ingester

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

Ingester writes content

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)

	// Update updates mutable information related to content.
	// If one or more fieldpaths are provided, only those
	// fields will be updated.
	// Mutable fields:
	//  labels.*
	Update(ctx context.Context, info Info, fieldpaths ...string) (Info, error)

	// Walk will call fn for each item in the content store which
	// match the provided filters. If no filters are given all
	// items will be walked.
	Walk(ctx context.Context, fn WalkFunc, filters ...string) error

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

Manager provides methods for inspecting, listing and removing content.

type Opt

type Opt func(*Info) error

Opt is used to alter the mutable properties of content

func WithLabels

func WithLabels(labels map[string]string) Opt

WithLabels allows labels to be set on content

type Provider

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

Provider provides a reader interface for specific content

type ReaderAt

type ReaderAt interface {
	io.ReaderAt
	io.Closer
	Size() int64
}

ReaderAt extends the standard io.ReaderAt interface with reporting of Size and io.Closer

type Status

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

Status of a content operation

type Store

type Store interface {
	Manager
	Provider
	IngestManager
	Ingester
}

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

type WalkFunc

type WalkFunc func(Info) error

WalkFunc defines the callback for a blob walk.

type Writer

type Writer interface {
	// Close is expected to be called after Commit() when commission is needed.
	// Closing a writer without commit allows resuming or aborting.
	io.WriteCloser

	// Digest may return empty digest or panics until committed.
	Digest() digest.Digest

	// Commit commits the blob (but no roll-back is guaranteed on an error).
	// size and expected can be zero-value when unknown.
	Commit(ctx context.Context, size int64, expected digest.Digest, opts ...Opt) error

	// Status returns the current state of write
	Status() (Status, error)

	// Truncate updates the size of the target blob
	Truncate(size int64) error
}

Writer handles the write of content into a content store

func OpenWriter

func OpenWriter(ctx context.Context, cs Ingester, ref string, size int64, expected digest.Digest) (Writer, error)

OpenWriter opens a new writer for the given reference, retrying if the writer is locked until the reference is available or returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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