package
0.20.3
Repository: https://github.com/google/go-containerregistry.git
Documentation: pkg.go.dev

# README

partial

GoDoc

Partial Implementations

There are roughly two kinds of image representations: compressed and uncompressed.

The implementations for these kinds of images are almost identical, with the only major difference being how blobs (config and layers) are fetched. This common code lives in this package, where you provide a partial implementation of a compressed or uncompressed image, and you get back a full v1.Image implementation.

Examples

In a registry, blobs are compressed, so it's easiest to implement a v1.Image in terms of compressed layers. remote.remoteImage does this by implementing CompressedImageCore:

type CompressedImageCore interface {
	RawConfigFile() ([]byte, error)
	MediaType() (types.MediaType, error)
	RawManifest() ([]byte, error)
	LayerByDigest(v1.Hash) (CompressedLayer, error)
}

In a tarball, blobs are (often) uncompressed, so it's easiest to implement a v1.Image in terms of uncompressed layers. tarball.uncompressedImage does this by implementing UncompressedImageCore:

type UncompressedImageCore interface {
	RawConfigFile() ([]byte, error)
	MediaType() (types.MediaType, error)
	LayerByDiffID(v1.Hash) (UncompressedLayer, error)
}

Optional Methods

Where possible, we access some information via optional methods as an optimization.

partial.Descriptor

There are some properties of a Descriptor that aren't derivable from just image data:

  • MediaType
  • Platform
  • URLs
  • Annotations

For example, in a tarball.Image, there is a LayerSources field that contains an entire layer descriptor with URLs information for foreign layers. This information can be passed through to callers by implementing this optional Descriptor method.

See #654.

partial.UncompressedSize

Usually, you don't need to know the uncompressed size of a layer, since that information isn't stored in a config file (just he sha256 is needed); however, there are cases where it is very helpful to know the layer size, e.g. when writing the uncompressed layer into a tarball.

See #655.

partial.Exists

We generally don't care about the existence of something as granular as a layer, and would rather ensure all the invariants of an image are upheld via the validate package. However, there are situations where we want to do a quick smoke test to ensure that the underlying storage engine hasn't been corrupted by something e.g. deleting files or blobs. Thus, we've exposed an optional Exists method that does an existence check without actually reading any bytes.

The remote package implements this via HEAD requests.

The layout package implements this via os.Stat.

See #838.

# Functions

ArtifactType returns the artifact type for the given manifest.
BlobDescriptor is a helper for implementing v1.Image.
BlobSize is a helper for implementing v1.Image.
BlobToDiffID is a helper for mapping between compressed and uncompressed blob hashes.
CompressedToImage fills in the missing methods from a CompressedImageCore so that it implements v1.Image.
CompressedToLayer fills in the missing methods from a CompressedLayer so that it implements v1.Layer.
ComputeManifests provides a fallback implementation for Manifests.
ConfigFile is a helper for implementing v1.Image.
ConfigLayer implements v1.Layer from the raw config bytes.
ConfigName is a helper for implementing v1.Image.
Descriptor returns a v1.Descriptor given a Describable.
DiffIDs is a helper for implementing v1.Image.
DiffIDToBlob is a helper for mapping between uncompressed and compressed blob hashes.
Digest is a helper for implementing v1.Image.
Exists checks to see if a layer exists.
FindImages given a v1.ImageIndex, find the images that fit the matcher.
FindIndexes given a v1.ImageIndex, find the indexes that fit the matcher.
FindManifests given a v1.ImageIndex, find the manifests that fit the matcher.
FSLayers is a helper for implementing v1.Image.
Manifest is a helper for implementing v1.Image.
Manifests is analogous to v1.Image.Layers in that it allows values in the returned list to be lazily evaluated, which enables an index to contain an image that contains a streaming layer.
RawConfigFile is a helper for implementing v1.Image.
RawManifest is a helper for implementing v1.Image.
Size is a helper for implementing v1.Image.
UncompressedSize returns the size of the Uncompressed layer.
UncompressedToImage fills in the missing methods from an UncompressedImageCore so that it implements v1.Image.
UncompressedToLayer fills in the missing methods from an UncompressedLayer so that it implements v1.Layer.

# Interfaces

CompressedImageCore represents the base minimum interface a natively compressed image must implement for us to produce a v1.Image.
CompressedLayer represents the bare minimum interface a natively compressed layer must implement for us to produce a v1.Layer.
Describable represents something for which we can produce a v1.Descriptor.
ImageCore is the core set of properties without which we cannot build a v1.Image.
UncompressedImageCore represents the bare minimum interface a natively uncompressed image must implement for us to produce a v1.Image.
UncompressedLayer represents the bare minimum interface a natively uncompressed layer must implement for us to produce a v1.Layer.
WithConfigFile defines the subset of v1.Image used by these helper methods.
WithDiffID defines the subset of v1.Layer for exposing the DiffID method.
WithManifest defines the subset of v1.Image used by these helper methods.
WithManifestAndConfigFile defines the subset of v1.Image used by these helper methods.
WithRawConfigFile defines the subset of v1.Image used by these helper methods.
WithRawManifest defines the subset of v1.Image used by these helper methods.