source

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package source resolves image references to the platform images to scan, pulling directly from the registry without a Docker daemon.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPlatform = errors.New("no matching platform")

ErrNoPlatform is returned when the filter matches no platform of an image.

Functions

func Resolve

func Resolve(ctx context.Context, ref string, opts Options) (repository, digest string, err error)

Resolve returns the repository and the digest a reference points to now, without fetching the image: for a tag, the digest of the manifest or index the registry serves, as the kubelet would pull it. If only the lookup fails, the repository is returned with the error.

Types

type Image

type Image struct {
	// Ref is the reference, or for a local input the name of the image in
	// it (the input path if it names none).
	Ref string
	// Input is the path of a local layout or archive, empty for a registry.
	Input string
	// Digest of the manifest or index the reference points to.
	Digest    string
	Platforms []PlatformImage
	// contains filtered or unexported fields
}

Image is a resolved image reference.

func Fetch

func Fetch(ctx context.Context, ref string, opts Options) (*Image, error)

Fetch resolves ref and returns the selected platform images. Layers are fetched lazily when they are read; a layer download that breaks off is resumed with an HTTP Range request.

func (*Image) Close

func (i *Image) Close() error

Close releases a local input once its layers are read; a no-op for registry images.

type Mirror

type Mirror struct {
	Registry string
	Prefix   string
}

Mirror serves the images of Registry under Prefix, e.g. a Harbor proxy cache project for Docker Hub: docker.io=harbor.example.com/dockerhub pulls docker.io/library/nginx from harbor.example.com/dockerhub/library/nginx. A mirror is trusted for tags; digests are verified.

func ParseMirror

func ParseMirror(s string) (Mirror, error)

ParseMirror parses "registry=host[/path]".

func (Mirror) String

func (m Mirror) String() string

type Options

type Options struct {
	Platforms PlatformFilter
	Keychain  authn.Keychain
	// Insecure allows plain HTTP registries (for tests and local registries).
	Insecure bool
	// Mirrors are tried in order before the registry itself, which is the
	// fallback if all fail (as containerd does).
	Mirrors []Mirror
	// Logger notes failed mirrors; nil for none.
	Logger *slog.Logger
	// Input reads the image from a local OCI image layout or docker save
	// archive instead of a registry; the reference then names the image in
	// it, empty for the only one. Close the Image when done.
	Input string
}

Options configure Fetch.

type PlatformFilter

type PlatformFilter struct {
	// contains filtered or unexported fields
}

PlatformFilter selects the platforms of a multi-arch image. The zero value selects all platforms.

func ParsePlatforms

func ParsePlatforms(s string) (PlatformFilter, error)

ParsePlatforms parses "all", "host" or a comma-separated list such as "linux/amd64,linux/arm64".

func (PlatformFilter) Match

func (f PlatformFilter) Match(p v1.Platform) bool

Match reports whether p is selected.

func (PlatformFilter) String

func (f PlatformFilter) String() string

type PlatformImage

type PlatformImage struct {
	Platform string
	Digest   string
	Image    v1.Image
}

PlatformImage is the image of one platform.

Jump to

Keyboard shortcuts

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