imgutil

package
v2.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FilterBeforeType    = "before"
	FilterSinceType     = "since"
	FilterLabelType     = "label"
	FilterReferenceType = "reference"
	FilterDanglingType  = "dangling"
)

Filter types supported to filter images.

Functions

func FilterByLabel

func FilterByLabel(ctx context.Context, client *containerd.Client, imageList []images.Image, filters map[string]string) ([]images.Image, error)

FilterByLabel filters images based on labels given in `filters`.

func FilterByReference

func FilterByReference(imageList []images.Image, filters []string) ([]images.Image, error)

FilterByReference filters images using references given in `filters`.

func FilterDangling

func FilterDangling(imageList []images.Image, dangling bool) []images.Image

FilterDangling filters dangling images (or keeps if `dangling` == false).

func FilterImages

func FilterImages(labelImages []images.Image, beforeImages []images.Image, sinceImages []images.Image) []images.Image

FilterImages returns images in `labelImages` that are created before MAX(beforeImages.CreatedAt) and after MIN(sinceImages.CreatedAt).

func ParseRepoTag

func ParseRepoTag(imgName string) (string, string)

ParseRepoTag parses raw `imgName` to repository and tag.

func ReadImageConfig

func ReadImageConfig(ctx context.Context, img containerd.Image) (ocispec.Image, ocispec.Descriptor, error)

ReadImageConfig reads the config spec (`application/vnd.oci.image.config.v1+json`) for img.platform from content store.

func ReadIndex

ReadIndex returns image index, or nil for non-indexed image.

func ReadManifest

func ReadManifest(ctx context.Context, img containerd.Image) (*ocispec.Manifest, *ocispec.Descriptor, error)

ReadManifest returns the manifest for img.platform, or nil if no manifest was found.

func ResolveDigest

func ResolveDigest(ctx context.Context, rawRef string, insecure bool, hostsDirs []string) (string, error)

ResolveDigest resolves `rawRef` and returns its descriptor digest.

func UnpackedImageSize

func UnpackedImageSize(ctx context.Context, s snapshots.Snapshotter, img containerd.Image) (int64, error)

UnpackedImageSize is the size of the unpacked snapshots. Does not contain the size of the blobs in the content store. (Corresponds to Docker).

Types

type EnsuredImage

type EnsuredImage struct {
	Ref         string
	Image       containerd.Image
	ImageConfig ocispec.ImageConfig
	Snapshotter string
	Remote      bool // true for stargz or overlaybd
}

EnsuredImage contains the image existed in containerd and its metadata.

func EnsureImage

func EnsureImage(ctx context.Context, client *containerd.Client, stdout, stderr io.Writer, snapshotter, rawRef string, mode PullMode, insecure bool, hostsDirs []string, ocispecPlatforms []ocispec.Platform, unpack *bool, quiet bool, rFlags types.RemoteSnapshotterFlags) (*EnsuredImage, error)

EnsureImage ensures the image.

When insecure is set, skips verifying certs, and also falls back to HTTP when the registry does not speak HTTPS

FIXME: this func has too many args

func GetExistingImage

func GetExistingImage(ctx context.Context, client *containerd.Client, snapshotter, rawRef string, platform ocispec.Platform) (*EnsuredImage, error)

GetExistingImage returns the specified image if exists in containerd. Return errdefs.NotFound() if not exists.

func PullImage

func PullImage(ctx context.Context, client *containerd.Client, stdout, stderr io.Writer, snapshotter string, resolver remotes.Resolver, ref string, ocispecPlatforms []ocispec.Platform, unpack *bool, quiet bool, rFlags types.RemoteSnapshotterFlags) (*EnsuredImage, error)

PullImage pulls an image using the specified resolver.

type Filters

type Filters struct {
	Before    []string
	Since     []string
	Labels    map[string]string
	Reference []string
	Dangling  *bool
}

Filters contains all types of filters to filter images.

func ParseFilters

func ParseFilters(filters []string) (*Filters, error)

ParseFilters parse filter strings.

type PullMode

type PullMode = string

PullMode is either one of "always", "missing", "never"

Directories

Path Synopsis
Package pull forked from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/content/fetch.go
Package pull forked from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/content/fetch.go
Package push derived from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/images/push.go
Package push derived from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/images/push.go

Jump to

Keyboard shortcuts

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