Documentation ¶
Index ¶
- Constants
- Variables
- func Check(ctx context.Context, provider content.Provider, image ocispec.Descriptor, ...) (available bool, required, present, missing []ocispec.Descriptor, err error)
- func Children(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) ([]ocispec.Descriptor, error)
- func Config(ctx context.Context, provider content.Provider, image ocispec.Descriptor, ...) (ocispec.Descriptor, error)
- func Dispatch(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) error
- func IsCompressedDiff(ctx context.Context, mediaType string) (bool, error)
- func Manifest(ctx context.Context, provider content.Provider, image ocispec.Descriptor, ...) (ocispec.Manifest, error)
- func Platforms(ctx context.Context, provider content.Provider, image ocispec.Descriptor) ([]ocispec.Platform, error)
- func RootFS(ctx context.Context, provider content.Provider, configDesc ocispec.Descriptor) ([]digest.Digest, error)
- func Walk(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) error
- type DeleteOpt
- type DeleteOptions
- type Exporter
- type Handler
- type HandlerFunc
- func ChildrenHandler(provider content.Provider) HandlerFunc
- func FilterPlatforms(f HandlerFunc, m platforms.Matcher) HandlerFunc
- func Handlers(handlers ...Handler) HandlerFunc
- func LimitManifests(f HandlerFunc, m platforms.MatchComparer, n int) HandlerFunc
- func SetChildrenLabels(manager content.Manager, f HandlerFunc) HandlerFunc
- type Image
- func (image *Image) Config(ctx context.Context, provider content.Provider, ...) (ocispec.Descriptor, error)
- func (image *Image) RootFS(ctx context.Context, provider content.Provider, ...) ([]digest.Digest, error)
- func (image *Image) Size(ctx context.Context, provider content.Provider, ...) (int64, error)
- type Importer
- type Store
Constants ¶
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 ¶
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 platforms.MatchComparer) (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 platforms.MatchComparer) (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 ¶
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
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 platforms.MatchComparer) (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.
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, m platforms.Matcher) HandlerFunc
FilterPlatforms is a handler wrapper which limits the descriptors returned based on matching the specified platform matcher.
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 LimitManifests ¶ added in v1.2.0
func LimitManifests(f HandlerFunc, m platforms.MatchComparer, n int) HandlerFunc
LimitManifests is a handler wrapper which filters the manifest descriptors returned using the provided platform. The results will be ordered according to the comparison operator and use the ordering in the manifests for equal matches. A limit of 0 or less is considered no limit.
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 platforms.MatchComparer) (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 platforms.MatchComparer) ([]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.
type Importer ¶
type Importer interface { // Import imports an image from a tar stream. Import(ctx context.Context, store content.Store, reader io.Reader) (ocispec.Descriptor, 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