Documentation ¶
Index ¶
- Constants
- func DestinationDirectory(options Options) string
- func FetchImageBlob(op trace.Operation, options Options, image *ImageWithMeta, ...) (string, error)
- func FetchImageManifest(op trace.Operation, options Options, schemaVersion int, ...) (interface{}, string, error)
- func FetchToken(op trace.Operation, options Options, url *url.URL, ...) (*urlfetcher.Token, error)
- func InitializeLayerCache(client *client.PortLayer) error
- func LearnAuthURL(op trace.Operation, options Options) (*url.URL, error)
- func LearnRegistryURL(op trace.Operation, options *Options) (string, error)
- func ListImages(op trace.Operation, host, storename string, images []*ImageWithMeta) (map[string]*models.Image, error)
- func PingPortLayer(op trace.Operation, host string) (bool, error)
- func UpdateRepoCache(ctx context.Context, ic *ImageC) error
- func WriteImage(op trace.Operation, host string, image *ImageWithMeta, data io.ReadCloser) error
- type FSLayer
- type History
- type ImageC
- func (ic *ImageC) CreateImageConfig(ctx context.Context, images []*ImageWithMeta) (metadata.ImageConfig, error)
- func (ic *ImageC) LayersToDownload(ctx context.Context) ([]*ImageWithMeta, error)
- func (ic *ImageC) ListLayers(ctx context.Context) error
- func (ic *ImageC) ParseReference(ctx context.Context)
- func (ic *ImageC) PullImage(ctx context.Context) error
- func (ic *ImageC) WriteImageBlob(ctx context.Context, image *ImageWithMeta, progressOutput progress.Output, ...) error
- type ImageWithMeta
- type LCache
- type LayerDownloader
- type LayerNotFoundError
- type Manifest
- type Options
Constants ¶
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 )
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 ¶
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 ¶
InitializeLayerCache will create a new layer cache or rehydrate an existing layer cache from the portlayer k/v store
func LearnAuthURL ¶
LearnAuthURL returns the URL of the OAuth endpoint
func LearnRegistryURL ¶
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 ¶
PingPortLayer calls the _ping endpoint of the portlayer
func UpdateRepoCache ¶
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 ¶
ListLayer prints out the layers for an image to progress. This is used by imagec standalone binary for debug/validation.
func (*ImageC) ParseReference ¶
ParseReference parses the -reference parameter and populate options struct
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 (*LCache) Commit ¶
func (lc *LCache) Commit(layer *ImageWithMeta) error
Commit marks a layer as downloaded
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