image

package
v5.31.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package image consolidates knowledge about various container image formats (as opposed to image storage mechanisms, which are handled by types.ImageSource) and exposes all of them using an unified interface.

Index

Constants

View Source
const GzippedEmptyLayerDigest = digest.Digest("sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4")

GzippedEmptyLayerDigest is a digest of GzippedEmptyLayer

This is publicly visible as c/image/image.GzippedEmptyLayerDigest.

Variables

View Source
var GzippedEmptyLayer = []byte{
	31, 139, 8, 0, 0, 9, 110, 136, 0, 255, 98, 24, 5, 163, 96, 20, 140, 88,
	0, 8, 0, 0, 255, 255, 46, 175, 181, 239, 0, 4, 0, 0,
}

GzippedEmptyLayer is a gzip-compressed version of an empty tar file (1024 NULL bytes) This comes from github.com/docker/distribution/manifest/schema1/config_builder.go; there is a non-zero embedded timestamp; we could zero that, but that would just waste storage space in registries, so let’s use the same values.

This is publicly visible as c/image/image.GzippedEmptyLayer.

Functions

func FromReference

func FromReference(ctx context.Context, sys *types.SystemContext, ref types.ImageReference) (types.ImageCloser, error)

FromReference returns a types.ImageCloser implementation for the default instance reading from reference. If reference points to a manifest list, .Manifest() still returns the manifest list, but other methods transparently return data from an appropriate image instance.

The caller must call .Close() on the returned ImageCloser.

NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource, verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage instead of calling this function.

func FromSource

FromSource returns a types.ImageCloser implementation for the default instance of source. If source is a manifest list, .Manifest() still returns the manifest list, but other methods transparently return data from an appropriate image instance.

The caller must call .Close() on the returned ImageCloser.

FromSource “takes ownership” of the input ImageSource and will call src.Close() when the image is closed. (This does not prevent callers from using both the Image and ImageSource objects simultaneously, but it means that they only need to the Image.)

NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource, verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage instead of calling this function.

Most callers can use either FromUnparsedImage or FromReference instead.

This is publicly visible as c/image/image.FromSource.

Types

type SourcedImage

type SourcedImage struct {
	*UnparsedImage
	ManifestBlob     []byte // The manifest of the relevant instance
	ManifestMIMEType string // MIME type of ManifestBlob
	// contains filtered or unexported fields
}

SourcedImage is a general set of utilities for working with container images, whatever is their underlying transport (i.e. ImageSource-independent). Note the existence of docker.Image and image.memoryImage: various instances of a types.Image may not be a SourcedImage directly.

Most external users of `types.Image` do not care, and those who care about `docker.Image` know they do.

Internal users may depend on methods available in SourcedImage but not (yet?) in types.Image.

func FromUnparsedImage

func FromUnparsedImage(ctx context.Context, sys *types.SystemContext, unparsed *UnparsedImage) (*SourcedImage, error)

FromUnparsedImage returns a types.Image implementation for unparsed. If unparsed represents a manifest list, .Manifest() still returns the manifest list, but other methods transparently return data from an appropriate single image.

The Image must not be used after the underlying ImageSource is Close()d.

This is publicly visible as c/image/image.FromUnparsedImage.

func (*SourcedImage) LayerInfosForCopy

func (i *SourcedImage) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error)

func (*SourcedImage) Manifest

func (i *SourcedImage) Manifest(ctx context.Context) ([]byte, string, error)

Manifest overrides the UnparsedImage.Manifest to always use the fields which we have already fetched.

func (*SourcedImage) Size

func (i *SourcedImage) Size() (int64, error)

Size returns the size of the image as stored, if it's known, or -1 if it isn't.

type UnparsedImage

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

UnparsedImage implements types.UnparsedImage . An UnparsedImage is a pair of (ImageSource, instance digest); it can represent either a manifest list or a single image instance.

This is publicly visible as c/image/image.UnparsedImage.

func UnparsedInstance

func UnparsedInstance(src types.ImageSource, instanceDigest *digest.Digest) *UnparsedImage

UnparsedInstance returns a types.UnparsedImage implementation for (source, instanceDigest). If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list).

The UnparsedImage must not be used after the underlying ImageSource is Close()d.

This is publicly visible as c/image/image.UnparsedInstance.

func (*UnparsedImage) Manifest

func (i *UnparsedImage) Manifest(ctx context.Context) ([]byte, string, error)

Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need.

func (*UnparsedImage) Reference

func (i *UnparsedImage) Reference() types.ImageReference

Reference returns the reference used to set up this source, _as specified by the user_ (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image.

func (*UnparsedImage) Signatures

func (i *UnparsedImage) Signatures(ctx context.Context) ([][]byte, error)

Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.

func (*UnparsedImage) UntrustedSignatures

func (i *UnparsedImage) UntrustedSignatures(ctx context.Context) ([]signature.Signature, error)

UntrustedSignatures is like ImageSource.GetSignaturesWithFormat, but the result is cached; it is OK to call this however often you need.

Jump to

Keyboard shortcuts

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