image

package
v0.0.0-...-60fc604 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package image provides common types to represent container images and their filesystem layers, based on the Go types defined by the OCI Image Layout Specification.

Index

Constants

This section is empty.

Variables

View Source
var (
	SupportedIndexMediaTypes = []string{
		specsv1.MediaTypeImageIndex,
		"application/vnd.docker.distribution.manifest.list.v2+json",
	}
	SupportedManifestMediaTypes = []string{
		specsv1.MediaTypeImageManifest,
		"application/vnd.docker.distribution.manifest.v2+json",
	}
)

Supported JSON manifest formats. The Docker-specific formats are compatible enough with the OCI-specified definitions that unmarshaling into the Go type defined by OCI should give us at least enough data to be useful.

Functions

This section is empty.

Types

type Config

type Config struct {
	specsv1.Image
	OSVersion  string   `json:"os.version,omitempty"`
	OSFeatures []string `json:"os.features,omitempty"`
	Variant    string   `json:"variant,omitempty"`
}

Config represents an OCI image configuration structure, extended with properties defined by the spec but not implemented in the upstream Go type as of this writing.

type Image

type Image struct {
	Layers []Layer
	// Config represents the OCI image configuration for this image.
	Config Config
	// Platform represents the "platform" value for this image in the "manifests"
	// array of an OCI image index.
	Platform specsv1.Platform
	// Annotations represents the "annotations" value for the OCI image manifest
	// associated with this image.
	Annotations map[string]string
}

Image represents a platform specific container image.

func (*Image) AppendLayer

func (img *Image) AppendLayer(layer Layer)

AppendLayer appends layer to img.Layers and updates corresponding values of img.Config.

func (*Image) SetPlatform

func (img *Image) SetPlatform(platform specsv1.Platform)

SetPlatform sets img.Platform and updates corresponding values of img.Config.

type Index

type Index []IndexEntry

Index represents an OCI image index that references platform specific container images.

func Load

func Load(ctx context.Context, l Loader) (Index, error)

Load builds an image index using the provided Loader. Methods on the returned Index, as well as on all Images loaded from the Index, will use the same Loader to access image configuration and filesystem layer blobs.

func (Index) SelectByPlatform

func (idx Index) SelectByPlatform(platform specsv1.Platform) Index

SelectByPlatform returns a new Index containing the subset of images in idx that are compatible with the provided platform, in order of decreasing preference, following standard platform matching rules as defined by https://pkg.go.dev/github.com/containerd/containerd/platforms.

type IndexEntry

type IndexEntry struct {
	Platform specsv1.Platform
	GetImage func(context.Context) (Image, error)
}

IndexEntry represents a reference to a platform specific container image in an OCI image index.

type Layer

type Layer struct {
	Descriptor specsv1.Descriptor
	DiffID     digest.Digest
	OpenBlob   func(context.Context) (io.ReadCloser, error)
}

Layer represents a single filesystem layer in a container image.

type Loader

type Loader interface {
	// RootDigest returns the digest of the raw contents of the JSON-encoded
	// entrypoint manifest if it is known in advance. If the digest is not known,
	// RootDigest returns ok == false along with an arbitrary but valid digest
	// value (for example, the digest of an empty input).
	RootDigest() (dgst digest.Digest, ok bool)
	// OpenRootManifest returns a reader for a JSON-encoded entrypoint manifest,
	// which may be an OCI image index, Docker v2 manifest list, OCI image
	// manifest, or Docker v2 image manifest.
	OpenRootManifest(context.Context) (io.ReadCloser, error)
	// OpenManifest returns a reader for a JSON-encoded manifest that matches the
	// provided digest, which may be an OCI image index, Docker v2 manifest list,
	// OCI image manifest, or Docker v2 image manifest.
	OpenManifest(context.Context, digest.Digest) (io.ReadCloser, error)
	// OpenBlob returns a reader for a blob whose content matches the provided
	// digest.
	OpenBlob(context.Context, digest.Digest) (io.ReadCloser, error)
}

Loader represents a source of manifest and blob information for container images.

Jump to

Keyboard shortcuts

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