graph

package
v1.4.2-0...-5276655 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2015 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTag = "latest"

DefaultTag defines the default tag used when performing images related actions and no tag string is specified

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

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

NewV2Repository creates a v2 only repository.

func SetupInitLayer

func SetupInitLayer(initLayer string) error

SetupInitLayer populates a directory with mountpoints suitable for bind-mounting dockerinit into the container. The mountpoint is simply an empty file at /.dockerinit This extra layer is used by all containers as the top-most ro layer. It protects the container from unwanted side-effects on the rw layer.

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) (*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 id 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

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 archive.ArchiveReader, 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) 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) GetDigest

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

GetDigest gets the digest for the provide image layer id.

func (*Graph) GetParent

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

GetParent returns the parent image.

func (*Graph) GetParentsSize

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

GetParentsSize returns the size of the parent.

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

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. FIXME: Implement error subclass instead of looking at the error text Note: This is the way golang implements os.IsNotExists on Plan9

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

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(img *image.Image, layerData archive.ArchiveReader) (err error)

Register imports a pre-existing image into the graph.

func (*Graph) Release

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

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

func (*Graph) Retain

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

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

func (*Graph) SetDigest

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

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

func (*Graph) TarLayer

func (graph *Graph) TarLayer(img *image.Image) (arch archive.Archive, 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

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 ImageExportConfig

type ImageExportConfig struct {
	// Names is the set of tags to export.
	Names []string
	// OutStream is the writer where the images are written to.
	Outstream io.Writer
}

ImageExportConfig holds list of names to be exported to a output stream. All images with the given tag and all versions containing the same tag are exported. The resulting output is an uncompressed tar ball.

type ImageImportConfig

type ImageImportConfig struct {
	// Changes are the container changes written to top layer.
	Changes []string
	// InConfig is the input stream containers layered data.
	InConfig io.ReadCloser
	// OutStream is the output stream where the image is written.
	OutStream io.Writer
	// ContainerConfig is the configuration of commit container.
	ContainerConfig *runconfig.Config
}

ImageImportConfig holds configuration to import a image.

type ImagePullConfig

type ImagePullConfig struct {
	// MetaHeaders store meta data about the image (DockerHeaders with prefix X-Meta- in the request).
	MetaHeaders map[string][]string
	// AuthConfig holds authentication information for authorizing 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

type ImagePushConfig struct {
	// MetaHeaders store meta data about the image (DockerHeaders with prefix X-Meta- in the request).
	MetaHeaders map[string][]string
	// AuthConfig holds authentication information for authorizing with the registry.
	AuthConfig *cliconfig.AuthConfig
	// Tag is the specific variant of the image to be pushed, this tag used when image is 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 ImagesConfig

type ImagesConfig struct {
	// Filters is supported list of filters used to get list of images.
	Filters string
	// Filter the list of images by name.
	Filter string
	// All inditest that all the images will be returned in the list, if set to true.
	All bool
}

ImagesConfig defines the criteria to obtain a list of images.

type Puller

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 to define Pull behavior.

func NewPuller

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

NewPuller returns a new instance of an implementation conforming to Puller interface.

type Pusher

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 to define Push behavior.

type Repository

type Repository map[string]string

Repository maps image id to image tag.

func (Repository) Contains

func (r Repository) Contains(u Repository) bool

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

func (Repository) Update

func (r Repository) Update(u Repository)

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

type TagStore

type TagStore struct {
	Repositories map[string]Repository

	sync.Mutex
	// contains filtered or unexported fields
}

TagStore contains information to push and pull to the repo.

func NewTagStore

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

NewTagStore creates a tag store to specified path.

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. Eg. {"43b5f19b10584": {"base:latest", "base:v1"}}

func (*TagStore) Delete

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

Delete removes a repo identified by a given name from the store

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 a repo from the store.

func (*TagStore) GetImage

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

GetImage returns an image from a given repo from the store.

func (*TagStore) GetRepoRefs

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

GetRepoRefs returns list of repos.

func (*TagStore) History

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

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

func (*TagStore) ImageExport

func (s *TagStore) ImageExport(imageExportConfig *ImageExportConfig) 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.

func (*TagStore) ImageName

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

ImageName returns name of the image.

func (*TagStore) ImageTarLayer

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

ImageTarLayer return the tarLayer of the image

func (*TagStore) Images

func (s *TagStore) Images(config *ImagesConfig) ([]*types.Image, error)

Images provide list of images based on selection criteria.

func (*TagStore) Import

func (s *TagStore) Import(src string, repo string, tag string, imageImportConfig *ImageImportConfig) error

Import allows to download image from a archive. If the src is a URL, the content is downloaded from the archive. If the source is '-' then the imageImportConfig.InConfig reader will be used to load the image. Once all the layers required are loaded locally, image is then tagged using the tag specified.

func (*TagStore) Load

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

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

Lookup return an image encoded in JSON

func (*TagStore) LookupImage

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

LookupImage returns the image from the store.

func (*TagStore) NewPusher

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

NewPusher returns a new instance of an implementation conforming to Pusher interface.

func (*TagStore) Pull

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

Pull downloads a image with specified name and tag from the repo.

func (*TagStore) Push

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

Push a image to the repo.

func (*TagStore) SetDigest

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

SetDigest creates a digest reference to an image ID.

func (*TagStore) SetLoad

func (store *TagStore) SetLoad(repoName, tag, imageName string, force bool, out io.Writer) error

SetLoad stores the image to the store. If the imageName is already in the repo then a '-f' flag should be used to replace existing image.

func (*TagStore) Tag

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

Tag adds a new tag to an existing image.

type TagStoreConfig

type TagStoreConfig struct {
	Graph    *Graph
	Key      libtrust.PrivateKey
	Registry *registry.Service
	Events   *events.Events
	Trust    *trust.TrustStore
}

TagStoreConfig holds tag store configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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