casext

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package casext provides extensions to the standard cas.Engine interface, allowing for generic functionality to be used on top of any implementation of cas.Engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob struct {
	// MediaType is the OCI media type of Data.
	MediaType string

	// Digest is the digest of the parsed image. Note that this does not update
	// if Data is changed (it is the digest that this blob was parsed *from*).
	Digest digest.Digest

	// Data is the "parsed" blob taken from the OCI image's blob store, and is
	// typed according to the media type. The mapping from MIME => type is as
	// follows.
	//
	// ispec.MediaTypeDescriptor => ispec.Descriptor
	// ispec.MediaTypeImageManifest => ispec.Manifest
	// ispec.MediaTypeImageManifestList => ispec.ManifestList
	// ispec.MediaTypeImageLayer => io.ReadCloser
	// ispec.MediaTypeImageLayerGzip => io.ReadCloser
	// ispec.MediaTypeImageLayerNonDistributable => io.ReadCloser
	// ispec.MediaTypeImageLayerNonDistributableGzip => io.ReadCloser
	// ispec.MediaTypeImageConfig => ispec.Image
	Data interface{}
}

Blob represents a "parsed" blob in an OCI image's blob store. MediaType offers a type-safe way of checking what the type of Data is.

func (*Blob) Close

func (b *Blob) Close()

Close cleans up all of the resources for the opened blob.

type Engine

type Engine struct {
	cas.Engine
}

Engine is a wrapper around cas.Engine that provides additional, generic extensions to the transport-dependent cas.Engine implementation.

func (Engine) FromDescriptor

func (e Engine) FromDescriptor(ctx context.Context, descriptor ispec.Descriptor) (*Blob, error)

FromDescriptor parses the blob referenced by the given descriptor.

func (Engine) GC

func (e Engine) GC(ctx context.Context) error

GC will perform a mark-and-sweep garbage collection of the OCI image referenced by the given CAS engine. The root set is taken to be the set of references stored in the image, and all blobs not reachable by following a descriptor path from the root set will be removed.

GC will only call ListBlobs and ListReferences once, and assumes that there is no change in the set of references or blobs after calling those functions. In other words, it assumes it is the only user of the image that is making modifications. Things will not go well if this assumption is challenged.

func (Engine) Paths

func (e Engine) Paths(ctx context.Context, root ispec.Descriptor) ([]ispec.Descriptor, error)

Paths returns the set of descriptors that can be traversed from the provided root descriptor. It is effectively shorthand for Walk(). Note that there may be repeated descriptors in the returned slice, due to different blobs containing the same (or a similar) descriptor.

func (Engine) Reachable

func (e Engine) Reachable(ctx context.Context, root ispec.Descriptor) ([]digest.Digest, error)

Reachable returns the set of digests which can be reached using a descriptor path from the provided root descriptor. It is effectively a shorthand for Walk(). The returned slice will *not* contain any duplicate digest.Digest entries. Note that without descriptors, a digest is not particularly meaninful (OCI blobs are not self-descriptive).

func (Engine) Walk

func (e Engine) Walk(ctx context.Context, root ispec.Descriptor, walkFunc WalkFunc) error

Walk preforms a depth-first walk from a given root descriptor, using the provided CAS engine to fetch all other necessary descriptors. If an error is returned by the provided WalkFunc, walking is terminated and the error is returned to the caller.

type WalkFunc

type WalkFunc func(descriptor ispec.Descriptor) error

WalkFunc is the type of function passed to Walk. It will be a called on each descriptor encountered, recursively -- which may involve the function being called on the same descriptor multiple times (though because an OCI image is a Merkle tree there will never be any loops). If an error is returned by WalkFunc, the recursion will halt and the error will bubble up to the caller.

Jump to

Keyboard shortcuts

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