imgutil

package
v2.0.0-rc.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Filter types supported to filter images.

Variables

This section is empty.

Functions

func ApplyFilters

func ApplyFilters(imageList []images.Image, filters ...Filter) ([]images.Image, error)

ApplyFilters applies each filter function in the order provided and returns the resulting filtered image list.

func GetDanglingImages

func GetDanglingImages(ctx context.Context, client *containerd.Client, filters ...Filter) ([]images.Image, error)

GetDanglingImages returns the list of all images which are not tagged.

func GetUnusedImages

func GetUnusedImages(ctx context.Context, client *containerd.Client, filters ...Filter) ([]images.Image, error)

GetUnusedImages returns the list of all images which are not referenced by a container.

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 ResourceUsage

func ResourceUsage(ctx context.Context, snapshotter snapshots.Snapshotter, resourceID string) (snapshots.Usage, snapshots.Usage, error)

ResourceUsage will return: - the Usage value of the resource referenced by ID - the cumulative Usage value of the resource, and all parents, recursively Typically, for a running container, this will equal the size of the read-write layer, plus the sum of the size of all layers in the base image

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, rawRef string, options types.ImagePullOptions) (*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

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, resolver remotes.Resolver, ref string, options types.ImagePullOptions) (*EnsuredImage, error)

PullImage pulls an image using the specified resolver.

type Filter

type Filter func([]images.Image) ([]images.Image, error)

func FilterByCreatedAt

func FilterByCreatedAt(ctx context.Context, client *containerd.Client, before []string, since []string) Filter

FilterByCreatedAt filters an image list to images created before MAX(before.<Image>.CreatedAt) and after MIN(since.<Image>.CreatedAt).

func FilterByLabel

func FilterByLabel(ctx context.Context, client *containerd.Client, labels map[string]string) Filter

FilterByLabel filters an image list based on labels applied to the image's config specification for the platform. Any matching label will include the image in the list.

func FilterByReference

func FilterByReference(referencePatterns []string) Filter

FilterByReference filters an image list based on <image:tag> matching the provided reference patterns

func FilterDanglingImages

func FilterDanglingImages() Filter

FilterDanglingImages filters an image list for dangling (untagged) images.

func FilterTaggedImages

func FilterTaggedImages() Filter

FilterTaggedImages filters an image list for tagged images.

func FilterUntil

func FilterUntil(until string) Filter

FilterUntil filters images created before the provided timestamp.

type Filters

type Filters struct {
	Before    []string
	Since     []string
	Until     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