imagec

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDestination specifies the default directory to use
	DefaultDestination = "images"

	// DefaultPortLayerHost specifies the default port layer server
	DefaultPortLayerHost = "localhost:2377"

	// DefaultLogfile specifies the default log file name
	DefaultLogfile = "imagec.log"

	// DefaultHTTPTimeout specifies the default HTTP timeout
	DefaultHTTPTimeout = 3600 * time.Second

	// attribute update actions
	Add = iota + 1
)
View Source
const (
	// DigestSHA256EmptyTar is the canonical sha256 digest of empty tar file -
	// (1024 NULL bytes)
	DigestSHA256EmptyTar = string(dlayer.DigestSHA256EmptyTar)
)

Variables

This section is empty.

Functions

func DestinationDirectory

func DestinationDirectory(options Options) string

DestinationDirectory returns the path of the output directory

func FetchImageBlob

func FetchImageBlob(op trace.Operation, options Options, image *ImageWithMeta, progressOutput progress.Output) (string, error)

FetchImageBlob fetches the image blob

func FetchImageManifest

func FetchImageManifest(op trace.Operation, options Options, schemaVersion int, progressOutput progress.Output) (interface{}, string, error)

FetchImageManifest fetches the image manifest file

func FetchToken

func FetchToken(op trace.Operation, options Options, url *url.URL, progressOutput progress.Output) (*urlfetcher.Token, error)

FetchToken fetches the OAuth token from OAuth endpoint

func InitializeLayerCache

func InitializeLayerCache(client *client.PortLayer) error

InitializeLayerCache will create a new layer cache or rehydrate an existing layer cache from the portlayer k/v store

func LearnAuthURL

func LearnAuthURL(op trace.Operation, options Options) (*url.URL, error)

LearnAuthURL returns the URL of the OAuth endpoint

func LearnRegistryURL

func LearnRegistryURL(op trace.Operation, options *Options) (string, error)

LearnRegistryURL returns the registry URL after making sure that it responds to queries

func ListImages

func ListImages(op trace.Operation, host, storename string, images []*ImageWithMeta) (map[string]*models.Image, error)

ListImages lists the images from given image store

func PingPortLayer

func PingPortLayer(op trace.Operation, host string) (bool, error)

PingPortLayer calls the _ping endpoint of the portlayer

func UpdateRepoCache

func UpdateRepoCache(ctx context.Context, ic *ImageC) error

UpdateRepositoryCache will update the repository cache that resides in the docker persona. This will add image tag, digest and layer information.

func WriteImage

func WriteImage(op trace.Operation, host string, image *ImageWithMeta, data io.ReadCloser) error

WriteImage writes the image to given image store

Types

type FSLayer

type FSLayer struct {
	// BlobSum is the tarsum of the referenced filesystem image layer
	BlobSum string `json:"blobSum"`
}

FSLayer is a container struct for BlobSums defined in an image manifest

type History

type History struct {
	V1Compatibility string `json:"v1Compatibility"`
}

History is a container struct for V1Compatibility defined in an image manifest

type ImageC

type ImageC struct {
	Options

	// ImageLayers are sourced from the manifest file
	ImageLayers []*ImageWithMeta

	// ImageID is the docker ImageID calculated during download
	ImageID string
	// contains filtered or unexported fields
}

ImageC is responsible for pulling docker images from a repository

func NewImageC

func NewImageC(options Options, strfmtr *streamformatter.StreamFormatter) *ImageC

NewImageC returns a new instance of ImageC

func (*ImageC) CreateImageConfig

func (ic *ImageC) CreateImageConfig(ctx context.Context, images []*ImageWithMeta) (metadata.ImageConfig, error)

CreateImageConfig constructs the image metadata from layers that compose the image

func (*ImageC) LayersToDownload

func (ic *ImageC) LayersToDownload(ctx context.Context) ([]*ImageWithMeta, error)

LayersToDownload creates a slice of ImageWithMeta for the layers that need to be downloaded

func (*ImageC) ListLayers

func (ic *ImageC) ListLayers(ctx context.Context) error

ListLayer prints out the layers for an image to progress. This is used by imagec standalone binary for debug/validation.

func (*ImageC) ParseReference

func (ic *ImageC) ParseReference(ctx context.Context)

ParseReference parses the -reference parameter and populate options struct

func (*ImageC) PullImage

func (ic *ImageC) PullImage(ctx context.Context) error

PullImage pulls an image from docker hub

func (*ImageC) WriteImageBlob

func (ic *ImageC) WriteImageBlob(ctx context.Context, image *ImageWithMeta, progressOutput progress.Output, cleanup bool) error

WriteImageBlob writes the image blob to the storage layer

type ImageWithMeta

type ImageWithMeta struct {
	*models.Image

	DiffID string
	Layer  FSLayer
	Meta   string
	Size   int64

	Downloading bool
}

ImageWithMeta wraps the models.Image with some additional metadata

func (*ImageWithMeta) String

func (i *ImageWithMeta) String() string

type LCache

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

LCache is an in-memory cache to account for existing image layers It is used primarily by imagec when coordinating layer downloads The cache is initially hydrated by way of the image cache at startup

func LayerCache

func LayerCache() *LCache

LayerCache returns a reference to the layer cache

func (*LCache) Add

func (lc *LCache) Add(layer *ImageWithMeta)

Add adds a new layer to the cache

func (*LCache) Commit

func (lc *LCache) Commit(layer *ImageWithMeta) error

Commit marks a layer as downloaded

func (*LCache) Get

func (lc *LCache) Get(id string) (*ImageWithMeta, error)

Get returns a cached layer, or LayerNotFoundError if it doesn't exist

func (*LCache) Remove

func (lc *LCache) Remove(id string)

Remove removes a layer from the cache

func (*LCache) Save

func (lc *LCache) Save() error

Save will persist the image cache to the portlayer k/v store

type LayerDownloader

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

LayerDownloader keeps track of what layers are currently being downloaded

func NewLayerDownloader

func NewLayerDownloader() *LayerDownloader

NewLayerDownloader creates and returns a new LayerDownloadManager

func (*LayerDownloader) DownloadLayers

func (ldm *LayerDownloader) DownloadLayers(ctx context.Context, ic *ImageC) error

DownloadLayers ensures layers end up in the portlayer's image store It handles existing and simultaneous layer download de-duplication This code is utilizes Docker's xfer package: https://github.com/docker/docker/tree/v1.11.2/distribution/xfer

type LayerNotFoundError

type LayerNotFoundError struct{}

LayerNotFoundError is returned when a layer does not exist in the cache

func (LayerNotFoundError) Error

func (e LayerNotFoundError) Error() string

type Manifest

type Manifest struct {
	Name     string    `json:"name"`
	Tag      string    `json:"tag"`
	Digest   string    `json:"digest,omitempty"`
	FSLayers []FSLayer `json:"fsLayers"`
	History  []History `json:"history"`
}

Manifest represents the Docker Manifest file

type Options

type Options struct {
	Reference reference.Named

	Registry string
	Image    string
	Tag      string

	Destination string

	Host      string
	Storename string

	Username string
	Password string

	Token *urlfetcher.Token

	Timeout time.Duration

	Outstream io.Writer

	InsecureSkipVerify bool
	InsecureAllowHTTP  bool

	// Get both schema 1 and schema 2 manifests.  Schema 1 is used to get history
	// and was imageC implementation predated schema 2.  Schema 2 is used to
	// calculate digest.
	ImageManifestSchema1 *Manifest
	ImageManifestSchema2 *schema2.DeserializedManifest

	//Digest of manifest schema 2 or schema 1; therefore, it may not match hash
	//of the above manifest.
	ManifestDigest string

	// RegistryCAs will not be modified by imagec
	RegistryCAs *x509.CertPool

	// If true, do not bother portlayer or persona
	Standalone bool

	// image store name or url
	ImageStore string
}

Options contain all options for a single instance of imagec

Jump to

Keyboard shortcuts

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