client

package
v2.0.1+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLayerAlreadyExists is returned when attempting to create a layer with
	// a tarsum that is already in use.
	ErrLayerAlreadyExists = fmt.Errorf("Layer already exists")

	// ErrLayerLocked is returned when attempting to write to a layer which is
	// currently being written to.
	ErrLayerLocked = fmt.Errorf("Layer locked")
)

Functions

func Pull

func Pull(c Client, objectStore ObjectStore, name, tag string) error

Pull implements a client pull workflow for the image defined by the given name and tag pair, using the given ObjectStore for local manifest and layer storage

func Push

func Push(c Client, objectStore ObjectStore, name, tag string) error

Push implements a client push workflow for the image defined by the given name and tag pair, using the given ObjectStore for local manifest and layer storage

Types

type BlobNotFoundError

type BlobNotFoundError struct {
	Name   string
	Digest digest.Digest
}

BlobNotFoundError is returned when making an operation against a given image layer that does not exist in the registry.

func (*BlobNotFoundError) Error

func (e *BlobNotFoundError) Error() string

type BlobUploadInvalidRangeError

type BlobUploadInvalidRangeError struct {
	Location       string
	LastValidRange int
	BlobSize       int
}

BlobUploadInvalidRangeError is returned when attempting to upload an image blob chunk that is out of order. This provides the known BlobSize and LastValidRange which can be used to resume the upload.

func (*BlobUploadInvalidRangeError) Error

type BlobUploadNotFoundError

type BlobUploadNotFoundError struct {
	Location string
}

BlobUploadNotFoundError is returned when making a blob upload operation against an invalid blob upload location url. This may be the result of using a cancelled, completed, or stale upload location.

func (*BlobUploadNotFoundError) Error

func (e *BlobUploadNotFoundError) Error() string

type Client

type Client interface {
	// GetImageManifest returns an image manifest for the image at the given
	// name, tag pair.
	GetImageManifest(name, tag string) (*manifest.SignedManifest, error)

	// PutImageManifest uploads an image manifest for the image at the given
	// name, tag pair.
	PutImageManifest(name, tag string, imageManifest *manifest.SignedManifest) error

	// DeleteImage removes the image at the given name, tag pair.
	DeleteImage(name, tag string) error

	// ListImageTags returns a list of all image tags with the given repository
	// name.
	ListImageTags(name string) ([]string, error)

	// BlobLength returns the length of the blob stored at the given name,
	// digest pair.
	// Returns a length value of -1 on error or if the blob does not exist.
	BlobLength(name string, dgst digest.Digest) (int, error)

	// GetBlob returns the blob stored at the given name, digest pair in the
	// form of an io.ReadCloser with the length of this blob.
	// A nonzero byteOffset can be provided to receive a partial blob beginning
	// at the given offset.
	GetBlob(name string, dgst digest.Digest, byteOffset int) (io.ReadCloser, int, error)

	// InitiateBlobUpload starts a blob upload in the given repository namespace
	// and returns a unique location url to use for other blob upload methods.
	InitiateBlobUpload(name string) (string, error)

	// GetBlobUploadStatus returns the byte offset and length of the blob at the
	// given upload location.
	GetBlobUploadStatus(location string) (int, int, error)

	// UploadBlob uploads a full blob to the registry.
	UploadBlob(location string, blob io.ReadCloser, length int, dgst digest.Digest) error

	// UploadBlobChunk uploads a blob chunk with a given length and startByte to
	// the registry.
	// FinishChunkedBlobUpload must be called to finalize this upload.
	UploadBlobChunk(location string, blobChunk io.ReadCloser, length, startByte int) error

	// FinishChunkedBlobUpload completes a chunked blob upload at a given
	// location.
	FinishChunkedBlobUpload(location string, length int, dgst digest.Digest) error

	// CancelBlobUpload deletes all content at the unfinished blob upload
	// location and invalidates any future calls to this blob upload.
	CancelBlobUpload(location string) error
}

Client implements the client interface to the registry http api

func New

func New(endpoint string) (Client, error)

New returns a new Client which operates against a registry with the given base endpoint This endpoint should not include /v2/ or any part of the url after this.

type ImageManifestNotFoundError

type ImageManifestNotFoundError struct {
	Name string
	Tag  string
}

ImageManifestNotFoundError is returned when making an operation against a given image manifest that does not exist in the registry.

func (*ImageManifestNotFoundError) Error

type Layer

type Layer interface {
	// Reader returns a LayerReader or an error if the layer has not been
	// written to or is currently being written to.
	Reader() (LayerReader, error)

	// Writer returns a LayerWriter or an error if the layer has been fully
	// written to or is currently being written to.
	Writer() (LayerWriter, error)

	// Wait blocks until the Layer can be read from.
	Wait() error
}

Layer is a generic image layer interface. A Layer may not be written to if it is already complete.

type LayerReader

type LayerReader interface {
	io.ReadCloser

	// CurrentSize returns the number of bytes written to the underlying Layer
	CurrentSize() int

	// Size returns the full size of the underlying Layer
	Size() int
}

LayerReader is a read-only handle to a Layer, which exposes the CurrentSize and full Size in addition to implementing the io.ReadCloser interface.

type LayerWriter

type LayerWriter interface {
	io.WriteCloser

	// CurrentSize returns the number of bytes written to the underlying Layer
	CurrentSize() int

	// Size returns the full size of the underlying Layer
	Size() int

	// SetSize sets the full size of the underlying Layer.
	// This must be called before any calls to Write
	SetSize(int) error
}

LayerWriter is a write-only handle to a Layer, which exposes the CurrentSize and full Size in addition to implementing the io.WriteCloser interface. SetSize must be called on this LayerWriter before it can be written to.

type ObjectStore

type ObjectStore interface {
	// Manifest retrieves the image manifest stored at the given repository name
	// and tag
	Manifest(name, tag string) (*manifest.SignedManifest, error)

	// WriteManifest stores an image manifest at the given repository name and
	// tag
	WriteManifest(name, tag string, manifest *manifest.SignedManifest) error

	// Layer returns a handle to a layer for reading and writing
	Layer(dgst digest.Digest) (Layer, error)
}

ObjectStore is an interface which is designed to approximate the docker engine storage. This interface is subject to change to conform to the future requirements of the engine.

type RepositoryNotFoundError

type RepositoryNotFoundError struct {
	Name string
}

RepositoryNotFoundError is returned when making an operation against a repository that does not exist in the registry.

func (*RepositoryNotFoundError) Error

func (e *RepositoryNotFoundError) Error() string

type UnexpectedHTTPStatusError

type UnexpectedHTTPStatusError struct {
	Status string
}

UnexpectedHTTPStatusError is returned when an unexpected HTTP status is returned when making a registry api call.

func (*UnexpectedHTTPStatusError) Error

func (e *UnexpectedHTTPStatusError) Error() string

Jump to

Keyboard shortcuts

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