blobstore

package module
v0.0.0-...-09509f1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

README

blobstore

A local blob storage system to be used by Docker 1.x

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashForLabel

func HashForLabel(label string) (h crypto.Hash)

HashForLabel return a crypto.Hash for the given digest label, e.g., "sha256". If the hash is not supported, `crypto.Hash(0)` is returned. Currently, only "sha256", "sha384", and "sha512" are supported.

Types

type Blob

type Blob interface {
	Descriptor
	// Open should open the underlying blob for reading. It is the
	// responsibility of the caller to close the returned io.ReadCloser.
	// Returns a nil error on success.
	Open() (io.ReadCloser, error)
}

Blob is the interface for accessing a blob.

type BlobWriter

type BlobWriter interface {
	io.Writer
	// Digest returns the digest of the data which has been written so far.
	Digest() string
	// Commit completes the blob writing process. The new blob is stored with
	// the given mediaType and starting refcount of 1. If another blob already
	// exists with the same computed digest then the reference is added to that
	// blob. If there is an error, it is of type Error.
	Commit() (Descriptor, error)
	// Cancel ends the writing process, cleaning up any temporary resources. If
	// there is an error, it is of type *Error.
	Cancel() error
}

BlobWriter provides a handle for writing a new blob to the blob store.

type Descriptor

type Descriptor interface {
	Digest() string
	Size() uint64
	RefCount() uint64
	Links() (linksTo []string)
}

Descriptor describes a blob.

type Error

type Error interface {
	error
	IsBlobNotExists() bool
}

Error is the error type returned by the Store interface.

type Store

type Store interface {
	// Get the blob with the given digest from this store.
	Get(digest string) (Blob, error)
	// List returns a slice of digest strings for each blob in this store.
	List() ([]string, error)
	// NewWriter begins the process of writing a new blob using the given hash
	// to compute the digest.
	NewWriter(crypto.Hash) (BlobWriter, error)
	// Ref increments the reference count for the blob with the given digest.
	Ref(digest string) (Descriptor, error)
	// Deref decrements the reference count for the blob with the given digest.
	// If no references to the blob remain, the blob will be removed from the
	// store and blobs to which it links will also be dereferenced.
	Deref(digest string) error
	// Link sets up a link between the blobs referenced by digests *to* and
	// *from*. Assumes an implicit reference from *from* to *to*.
	Link(to, from string) error
	// Unlink removes a link between the blobs referenced by digests *to* and
	// *from*. Also dereferences the *to* blob.
	Unlink(to, from string) error
}

Store is the interface for managing image manifest and rootfs diff blobs. Any errors returned by this interface are of type Error.

func NewLocalStore

func NewLocalStore(root string) (Store, error)

NewLocalStore creates a new local blob store in the given root directory.

Jump to

Keyboard shortcuts

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