images

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MediaTypeDockerSchema2Layer            = "application/vnd.docker.image.rootfs.diff.tar"
	MediaTypeDockerSchema2LayerForeign     = "application/vnd.docker.image.rootfs.foreign.diff.tar"
	MediaTypeDockerSchema2LayerGzip        = "application/vnd.docker.image.rootfs.diff.tar.gzip"
	MediaTypeDockerSchema2LayerForeignGzip = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
	MediaTypeDockerSchema2Config           = "application/vnd.docker.container.image.v1+json"
	MediaTypeDockerSchema2Manifest         = "application/vnd.docker.distribution.manifest.v2+json"
	MediaTypeDockerSchema2ManifestList     = "application/vnd.docker.distribution.manifest.list.v2+json"
	// Checkpoint/Restore Media Types
	MediaTypeContainerd1Checkpoint        = "application/vnd.containerd.container.criu.checkpoint.criu.tar"
	MediaTypeContainerd1CheckpointPreDump = "application/vnd.containerd.container.criu.checkpoint.predump.tar"
	MediaTypeContainerd1Resource          = "application/vnd.containerd.container.resource.tar"
	MediaTypeContainerd1RW                = "application/vnd.containerd.container.rw.tar"
	MediaTypeContainerd1CheckpointConfig  = "application/vnd.containerd.container.checkpoint.config.v1+proto"
	// Legacy Docker schema1 manifest
	MediaTypeDockerSchema1Manifest = "application/vnd.docker.distribution.manifest.v1+prettyjws"
)

mediatype definitions for image components handled in containerd.

oci components are generally referenced directly, although we may centralize here for clarity.

Variables

View Source
var (
	// ErrSkipDesc is used to skip processing of a descriptor and
	// its descendants.
	ErrSkipDesc = fmt.Errorf("skip descriptor")

	// ErrStopHandler is used to signify that the descriptor
	// has been handled and should not be handled further.
	// This applies only to a single descriptor in a handler
	// chain and does not apply to descendant descriptors.
	ErrStopHandler = fmt.Errorf("stop handler")
)

Functions

func Check

func Check(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (available bool, required, present, missing []ocispec.Descriptor, err error)

Check returns nil if the all components of an image are available in the provider for the specified platform.

If available is true, the caller can assume that required represents the complete set of content required for the image.

missing will have the components that are part of required but not avaiiable in the provider.

If there is a problem resolving content, an error will be returned.

func Children

func Children(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) ([]ocispec.Descriptor, error)

Children returns the immediate children of content described by the descriptor.

func Config

func Config(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (ocispec.Descriptor, error)

Config resolves the image configuration descriptor using a content provided to resolve child resources on the image.

The caller can then use the descriptor to resolve and process the configuration of the image.

func Dispatch

func Dispatch(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) error

Dispatch runs the provided handler for content specified by the descriptors. If the handler decode subresources, they will be visited, as well.

Handlers for siblings are run in parallel on the provided descriptors. A handler may return `ErrSkipDesc` to signal to the dispatcher to not traverse any children.

Typically, this function will be used with `FetchHandler`, often composed with other handlers.

If any handler returns an error, the dispatch session will be canceled.

func IsCompressedDiff added in v1.1.0

func IsCompressedDiff(ctx context.Context, mediaType string) (bool, error)

IsCompressedDiff returns true if mediaType is a known compressed diff media type. It returns false if the media type is a diff, but not compressed. If the media type is not a known diff type, it returns errdefs.ErrNotImplemented

func Manifest

func Manifest(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform string) (ocispec.Manifest, error)

Manifest resolves a manifest from the image for the given platform.

TODO(stevvooe): This violates the current platform agnostic approach to this package by returning a specific manifest type. We'll need to refactor this to return a manifest descriptor or decide that we want to bring the API in this direction because this abstraction is not needed.`

func Platforms

func Platforms(ctx context.Context, provider content.Provider, image ocispec.Descriptor) ([]ocispec.Platform, error)

Platforms returns one or more platforms supported by the image.

func RootFS

func RootFS(ctx context.Context, provider content.Provider, configDesc ocispec.Descriptor) ([]digest.Digest, error)

RootFS returns the unpacked diffids that make up and images rootfs.

These are used to verify that a set of layers unpacked to the expected values.

func Walk

func Walk(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) error

Walk the resources of an image and call the handler for each. If the handler decodes the sub-resources for each image,

This differs from dispatch in that each sibling resource is considered synchronously.

Types

type DeleteOpt

type DeleteOpt func(context.Context, *DeleteOptions) error

DeleteOpt allows configuring a delete operation

func SynchronousDelete

func SynchronousDelete() DeleteOpt

SynchronousDelete is used to indicate that an image deletion and removal of the image resources should occur synchronously before returning a result.

type DeleteOptions

type DeleteOptions struct {
	Synchronous bool
}

DeleteOptions provide options on image delete

type Exporter

type Exporter interface {
	// Export exports an image to a tar stream.
	Export(ctx context.Context, store content.Provider, desc ocispec.Descriptor, writer io.Writer) error
}

Exporter is the interface for image exporter.

type Handler

type Handler interface {
	Handle(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error)
}

Handler handles image manifests

type HandlerFunc

type HandlerFunc func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error)

HandlerFunc function implementing the Handler interface

func ChildrenHandler

func ChildrenHandler(provider content.Provider) HandlerFunc

ChildrenHandler decodes well-known manifest types and returns their children.

This is useful for supporting recursive fetch and other use cases where you want to do a full walk of resources.

One can also replace this with another implementation to allow descending of arbitrary types.

func FilterPlatforms added in v1.1.0

func FilterPlatforms(f HandlerFunc, platformList ...string) HandlerFunc

FilterPlatforms is a handler wrapper which limits the descriptors returned by a handler to the specified platforms.

func Handlers

func Handlers(handlers ...Handler) HandlerFunc

Handlers returns a handler that will run the handlers in sequence.

A handler may return `ErrStopHandler` to stop calling additional handlers

func SetChildrenLabels added in v1.1.0

func SetChildrenLabels(manager content.Manager, f HandlerFunc) HandlerFunc

SetChildrenLabels is a handler wrapper which sets labels for the content on the children returned by the handler and passes through the children. Must follow a handler that returns the children to be labeled.

func (HandlerFunc) Handle

func (fn HandlerFunc) Handle(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error)

Handle image manifests

type Image

type Image struct {
	// Name of the image.
	//
	// To be pulled, it must be a reference compatible with resolvers.
	//
	// This field is required.
	Name string

	// Labels provide runtime decoration for the image record.
	//
	// There is no default behavior for how these labels are propagated. They
	// only decorate the static metadata object.
	//
	// This field is optional.
	Labels map[string]string

	// Target describes the root content for this image. Typically, this is
	// a manifest, index or manifest list.
	Target ocispec.Descriptor

	CreatedAt, UpdatedAt time.Time
}

Image provides the model for how containerd views container images.

func (*Image) Config

func (image *Image) Config(ctx context.Context, provider content.Provider, platform string) (ocispec.Descriptor, error)

Config resolves the image configuration descriptor.

The caller can then use the descriptor to resolve and process the configuration of the image.

func (*Image) RootFS

func (image *Image) RootFS(ctx context.Context, provider content.Provider, platform string) ([]digest.Digest, error)

RootFS returns the unpacked diffids that make up and images rootfs.

These are used to verify that a set of layers unpacked to the expected values.

func (*Image) Size

func (image *Image) Size(ctx context.Context, provider content.Provider, platform string) (int64, error)

Size returns the total size of an image's packed resources.

type Importer

type Importer interface {
	// Import imports an image from a tar stream.
	Import(ctx context.Context, store content.Store, reader io.Reader) ([]Image, error)
}

Importer is the interface for image importer.

type Store

type Store interface {
	Get(ctx context.Context, name string) (Image, error)
	List(ctx context.Context, filters ...string) ([]Image, error)
	Create(ctx context.Context, image Image) (Image, error)

	// Update will replace the data in the store with the provided image. If
	// one or more fieldpaths are provided, only those fields will be updated.
	Update(ctx context.Context, image Image, fieldpaths ...string) (Image, error)

	Delete(ctx context.Context, name string, opts ...DeleteOpt) error
}

Store and interact with images

Directories

Path Synopsis
Package oci provides the importer and the exporter for OCI Image Spec.
Package oci provides the importer and the exporter for OCI Image Spec.

Jump to

Keyboard shortcuts

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