graph

package
v1.9.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const MaxImageDepth = 127

Set the max depth to the aufs default that most kernels are compiled with For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk

Variables

View Source
var (
	// ErrDigestNotSet is used when request the digest for a layer
	// but the layer has no digest value or content to compute the
	// the digest.
	ErrDigestNotSet = errors.New("digest is not set for layer")
)

Functions

func NewV2Repository added in v1.8.0

func NewV2Repository(repoInfo *registry.RepositoryInfo, endpoint registry.APIEndpoint, metaHeaders http.Header, authConfig *cliconfig.AuthConfig, actions ...string) (distribution.Repository, error)

NewV2Repository returns a repository (v2 only). It creates a HTTP transport providing timeout settings and authentication support, and also verifies the remote API version.

Types

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

A Graph is a store for versioned filesystem images and the relationship between them.

func NewGraph

func NewGraph(root string, driver graphdriver.Driver, uidMaps, gidMaps []idtools.IDMap) (*Graph, error)

NewGraph instantiates a new graph at the given root path in the filesystem. `root` will be created if it doesn't exist.

func (*Graph) ByParent

func (graph *Graph) ByParent() map[string][]*image.Image

ByParent returns a lookup table of images by their parent. If an image of key ID has 3 children images, then the value for key ID will be a list of 3 images. If an image has no children, it will not have an entry in the table.

func (*Graph) CheckDepth added in v1.8.0

func (graph *Graph) CheckDepth(img *image.Image) error

CheckDepth returns an error if the depth of an image, as returned by ImageDepth, is too large to support creating a container from it on this daemon.

func (*Graph) Create

func (graph *Graph) Create(layerData io.Reader, containerID, containerImage, comment, author string, containerConfig, config *runconfig.Config) (*image.Image, error)

Create creates a new image and registers it in the graph.

func (*Graph) Delete

func (graph *Graph) Delete(name string) error

Delete atomically removes an image from the graph.

func (*Graph) Exists

func (graph *Graph) Exists(id string) bool

Exists returns true if an image is registered at the given id. If the image doesn't exist or if an error is encountered, false is returned.

func (*Graph) GenerateV1CompatibilityChain added in v1.8.3

func (graph *Graph) GenerateV1CompatibilityChain(id string) ([]byte, error)

GenerateV1CompatibilityChain makes sure v1Compatibility JSON data exists for the image. If it doesn't it generates and stores it for the image and all of it's parents based on the image config JSON.

func (*Graph) Get

func (graph *Graph) Get(name string) (*image.Image, error)

Get returns the image with the given id, or an error if the image doesn't exist.

func (*Graph) GetLayerDigest added in v1.8.3

func (graph *Graph) GetLayerDigest(id string) (digest.Digest, error)

GetLayerDigest gets the digest for the provide image layer id.

func (*Graph) GetParent added in v1.8.0

func (graph *Graph) GetParent(img *image.Image) (*image.Image, error)

GetParent returns the parent image for the specified image.

func (*Graph) GetParentsSize added in v1.8.0

func (graph *Graph) GetParentsSize(img *image.Image) int64

GetParentsSize returns the combined size of all parent images. If there is no parent image or it's unavailable, it returns 0.

func (*Graph) GetV1CompatibilityConfig added in v1.8.3

func (graph *Graph) GetV1CompatibilityConfig(id string) ([]byte, error)

GetV1CompatibilityConfig reads the v1Compatibility JSON data for the image from the disk

func (*Graph) HasChildren added in v1.9.0

func (graph *Graph) HasChildren(imgID string) bool

HasChildren returns whether the given image has any child images.

func (*Graph) Heads

func (graph *Graph) Heads() map[string]*image.Image

Heads returns all heads in the graph, keyed by id. A head is an image which is not the parent of another image in the graph.

func (*Graph) IsHeld added in v1.8.0

func (graph *Graph) IsHeld(layerID string) bool

IsHeld returns whether the given layerID is being used by an ongoing pull or build.

func (*Graph) IsNotExist

func (graph *Graph) IsNotExist(err error, id string) bool

IsNotExist detects whether an image exists by parsing the incoming error message.

func (*Graph) Map

func (graph *Graph) Map() map[string]*image.Image

Map returns a list of all images in the graph, addressable by ID.

func (*Graph) RawJSON added in v1.8.0

func (graph *Graph) RawJSON(id string) ([]byte, error)

RawJSON returns the JSON representation for an image as a byte array.

func (*Graph) Register

func (graph *Graph) Register(im image.Descriptor, layerData io.Reader) (err error)

Register imports a pre-existing image into the graph. Returns nil if the image is already registered.

func (*Graph) Release added in v1.8.0

func (graph *Graph) Release(sessionID string, layerIDs ...string)

Release removes the referenced image ID from the provided set of layers.

func (*Graph) Retain added in v1.8.0

func (graph *Graph) Retain(sessionID string, layerIDs ...string)

Retain keeps the images and layers that are in the pulling chain so that they are not deleted. If not retained, they may be deleted by rmi.

func (*Graph) SetLayerDigest added in v1.8.3

func (graph *Graph) SetLayerDigest(id string, dgst digest.Digest) error

SetLayerDigest sets the digest for the image layer to the provided value.

func (*Graph) SetV1CompatibilityConfig added in v1.8.3

func (graph *Graph) SetV1CompatibilityConfig(id string, data []byte) error

SetV1CompatibilityConfig stores the v1Compatibility JSON data associated with the image in the manifest to the disk

func (*Graph) TarLayer added in v1.8.0

func (graph *Graph) TarLayer(img *image.Image) (arch io.ReadCloser, err error)

TarLayer returns a tar archive of the image's filesystem layer.

func (*Graph) TempLayerArchive

func (graph *Graph) TempLayerArchive(id string, sf *streamformatter.StreamFormatter, output io.Writer) (*archive.TempArchive, error)

TempLayerArchive creates a temporary archive of the given image's filesystem layer.

The archive is stored on disk and will be automatically deleted as soon as has been read.
If output is not nil, a human-readable progress bar will be written to it.

func (*Graph) WalkHistory added in v1.8.0

func (graph *Graph) WalkHistory(img *image.Image, handler func(image.Image) error) (err error)

WalkHistory calls the handler function for each image in the provided images lineage starting from immediate parent.

type ImagePullConfig added in v1.7.0

type ImagePullConfig struct {
	// MetaHeaders stores HTTP headers with metadata about the image
	// (DockerHeaders with prefix X-Meta- in the request).
	MetaHeaders map[string][]string
	// AuthConfig holds authentication credentials for authenticating with
	// the registry.
	AuthConfig *cliconfig.AuthConfig
	// OutStream is the output writer for showing the status of the pull
	// operation.
	OutStream io.Writer
}

ImagePullConfig stores pull configuration.

type ImagePushConfig added in v1.7.0

type ImagePushConfig struct {
	// MetaHeaders store HTTP headers with metadata about the image
	// (DockerHeaders with prefix X-Meta- in the request).
	MetaHeaders map[string][]string
	// AuthConfig holds authentication credentials for authenticating with
	// the registry.
	AuthConfig *cliconfig.AuthConfig
	// Tag is the specific variant of the image to be pushed.
	// If no tag is provided, all tags will be pushed.
	Tag string
	// OutStream is the output writer for showing the status of the push
	// operation.
	OutStream io.Writer
}

ImagePushConfig stores push configuration.

type Puller added in v1.8.0

type Puller interface {
	// Pull tries to pull the image referenced by `tag`
	// Pull returns an error if any, as well as a boolean that determines whether to retry Pull on the next configured endpoint.
	//
	// TODO(tiborvass): have Pull() take a reference to repository + tag, so that the puller itself is repository-agnostic.
	Pull(tag string) (fallback bool, err error)
}

Puller is an interface that abstracts pulling for different API versions.

func NewPuller added in v1.8.0

func NewPuller(s *TagStore, endpoint registry.APIEndpoint, repoInfo *registry.RepositoryInfo, imagePullConfig *ImagePullConfig, sf *streamformatter.StreamFormatter) (Puller, error)

NewPuller returns a Puller interface that will pull from either a v1 or v2 registry. The endpoint argument contains a Version field that determines whether a v1 or v2 puller will be created. The other parameters are passed through to the underlying puller implementation for use during the actual pull operation.

type Pusher added in v1.8.0

type Pusher interface {
	// Push tries to push the image configured at the creation of Pusher.
	// Push returns an error if any, as well as a boolean that determines whether to retry Push on the next configured endpoint.
	//
	// TODO(tiborvass): have Push() take a reference to repository + tag, so that the pusher itself is repository-agnostic.
	Push() (fallback bool, err error)
}

Pusher is an interface that abstracts pushing for different API versions.

type Repository

type Repository map[string]string

Repository maps tags to image IDs.

func (Repository) Contains added in v1.3.0

func (r Repository) Contains(u Repository) bool

Contains returns true if the contents of Repository u are wholly contained in Repository r.

func (Repository) Update added in v1.3.0

func (r Repository) Update(u Repository)

Update updates repository mapping with content of repository 'u'.

type TagStore

type TagStore struct {

	// Repositories is a map of repositories, indexed by name.
	Repositories map[string]Repository

	sync.Mutex
	// contains filtered or unexported fields
}

TagStore manages repositories. It encompasses the Graph used for versioned storage, as well as various services involved in pushing and pulling repositories.

func NewTagStore

func NewTagStore(path string, cfg *TagStoreConfig) (*TagStore, error)

NewTagStore creates a new TagStore at specified path, using the parameters and services provided in cfg.

func (*TagStore) ByID

func (store *TagStore) ByID() map[string][]string

ByID returns a reverse-lookup table of all the names which refer to each image - e.g. {"43b5f19b10584": {"base:latest", "base:v1"}}

func (*TagStore) Delete

func (store *TagStore) Delete(repoName, ref string) (bool, error)

Delete deletes a repository or a specific tag. If ref is empty, the entire repository named repoName will be deleted; otherwise only the tag named by ref will be deleted.

func (*TagStore) DeleteAll

func (store *TagStore) DeleteAll(id string) error

DeleteAll removes images identified by a specific ID from the store.

func (*TagStore) Get

func (store *TagStore) Get(repoName string) (Repository, error)

Get returns the Repository tag/image map for a given repository.

func (*TagStore) GetImage

func (store *TagStore) GetImage(repoName, refOrID string) (*image.Image, error)

GetImage returns a pointer to an Image structure describing the image referred to by refOrID inside repository repoName.

func (*TagStore) GetRepoRefs added in v0.12.0

func (store *TagStore) GetRepoRefs() map[string][]string

GetRepoRefs returns a map with image IDs as keys, and slices listing repo/tag references as the values. It covers all repositories.

func (*TagStore) HasReferences added in v1.9.0

func (store *TagStore) HasReferences(img *image.Image) bool

HasReferences returns whether or not the given image is referenced in one or more repositories.

func (*TagStore) History added in v1.7.0

func (s *TagStore) History(name string) ([]*types.ImageHistory, error)

History returns a slice of ImageHistory structures for the specified image name by walking the image lineage.

func (*TagStore) ImageExport added in v1.7.0

func (s *TagStore) ImageExport(names []string, outStream io.Writer) error

ImageExport exports list of images to a output stream specified in the config. The exported images are archived into a tar when written to the output stream. All images with the given tag and all versions containing the same tag are exported. names is the set of tags to export, and outStream is the writer which the images are written to.

func (*TagStore) ImageName

func (store *TagStore) ImageName(id string) string

ImageName returns name of an image, given the image's ID.

func (*TagStore) ImageTarLayer added in v1.7.0

func (s *TagStore) ImageTarLayer(name string, dest io.Writer) error

ImageTarLayer return the tarLayer of the image

func (*TagStore) Images added in v1.7.0

func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image, error)

Images returns a filtered list of images. filterArgs is a JSON-encoded set of filter arguments which will be interpreted by pkg/parsers/filters. filter is a shell glob string applied to repository names. The argument named all controls whether all images in the graph are filtered, or just the heads.

func (*TagStore) Import added in v1.7.0

func (s *TagStore) Import(src string, repo string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, containerConfig *runconfig.Config) error

Import imports an image, getting the archived layer data either from inConfig (if src is "-"), or from a URI specified in src. Progress output is written to outStream. Repository and tag names can optionally be given in the repo and tag arguments, respectively.

func (*TagStore) Load added in v1.7.0

func (s *TagStore) Load(inTar io.ReadCloser, outStream io.Writer) error

Load uploads a set of images into the repository. This is the complementary of ImageExport. The input stream is an uncompressed tar ball containing images and metadata.

func (*TagStore) Lookup added in v1.7.0

func (s *TagStore) Lookup(name string) (*types.ImageInspect, error)

Lookup looks up an image by name in a TagStore and returns it as an ImageInspect structure.

func (*TagStore) LookupImage

func (store *TagStore) LookupImage(name string) (*image.Image, error)

LookupImage returns pointer to an Image struct corresponding to the given name. The name can include an optional tag; otherwise the default tag will be used.

func (*TagStore) NewPusher added in v1.8.0

func (s *TagStore) NewPusher(endpoint registry.APIEndpoint, localRepo Repository, repoInfo *registry.RepositoryInfo, imagePushConfig *ImagePushConfig, sf *streamformatter.StreamFormatter) (Pusher, error)

NewPusher creates a new Pusher interface that will push to either a v1 or v2 registry. The endpoint argument contains a Version field that determines whether a v1 or v2 pusher will be created. The other parameters are passed through to the underlying pusher implementation for use during the actual push operation.

func (*TagStore) Pull added in v1.7.0

func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig) error

Pull initiates a pull operation. image is the repository name to pull, and tag may be either empty, or indicate a specific tag to pull.

func (*TagStore) Push added in v1.7.0

func (s *TagStore) Push(localName string, imagePushConfig *ImagePushConfig) error

Push initiates a push operation on the repository named localName.

func (*TagStore) SetDigest added in v1.6.0

func (store *TagStore) SetDigest(repoName, digest, imageName string) error

SetDigest creates a digest reference to an image ID.

func (*TagStore) Tag added in v1.7.0

func (store *TagStore) Tag(repoName, tag, imageName string, force bool) error

Tag creates a tag in the repository reponame, pointing to the image named imageName. If force is true, an existing tag with the same name may be overwritten.

type TagStoreConfig added in v1.7.0

type TagStoreConfig struct {
	// Graph is the versioned image store
	Graph *Graph
	// Key is the private key to use for signing manifests.
	Key libtrust.PrivateKey
	// Registry is the registry service to use for TLS configuration and
	// endpoint lookup.
	Registry *registry.Service
	// Events is the events service to use for logging.
	Events *events.Events
}

TagStoreConfig provides parameters for a new TagStore.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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