image

package
v1.6.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeURL added in v1.6.0

func NormalizeURL(repoURL string) string

NormalizeURL normalizes image repository URLs. Notably, hostnames docker.io and index.docker.io, if present, are dropped. The optional /library prefix for official images from Docker Hub, if included, is also dropped. Valid, non-Docker Hub repository URLs will be returned unchanged.

This is useful for the purposes of comparison and also in cases where a canonical representation of a repository URL is needed. Any URL that cannot be normalized will be returned as-is.

func ValidatePlatformConstraint

func ValidatePlatformConstraint(platformStr string) bool

ValidatePlatformConstraint returns a boolean indicating whether the provided platform constraint string is valid.

Types

type Credentials

type Credentials struct {
	// Username identifies a principal, which combined with the value of the
	// Password field, can be used for reading from some image repository.
	Username string
	// Password, when combined with the principal identified by the Username
	// field, can be used for reading from some image repository.
	Password string
}

Credentials represents the credentials for connecting to a private image repository.

type Image added in v0.4.0

type Image struct {
	Tag         string
	Digest      string
	Annotations map[string]string
	CreatedAt   *time.Time
	// contains filtered or unexported fields
}

Image is a representation of a container image.

type SelectionStrategy added in v0.4.0

type SelectionStrategy string

SelectionStrategy represents a strategy for selecting a single image from a container image repository.

const (
	// SelectionStrategyDigest represents an image selection strategy that is
	// useful for finding the digest of a container image that is currently
	// referenced by a mutable tag, e.g. latest. This strategy requires the use of
	// a constraint that must exactly match the name of a, presumably, mutable
	// tag.
	SelectionStrategyDigest SelectionStrategy = "Digest"
	// SelectionStrategyLexical represents an image selection strategy that is
	// useful for finding the image referenced by the tag that is lexically
	// last among those matched by a regular expression and not explicitly
	// ignored. This strategy is useful for finding the images referenced by the
	// latest in a series of tag that are suffixed with a predictably formatted
	// timestamp.
	SelectionStrategyLexical SelectionStrategy = "Lexical"
	// SelectionStrategyNewestBuild represents an image selection strategy that is
	// useful for finding the image that was most recently pushed to the image
	// repository. This is the least efficient strategy because it can require the
	// retrieval of many manifests from the image repository. It is best to use
	// this strategy with caution and constrain the eligible tags as much as
	// possible using a regular expression.
	SelectionStrategyNewestBuild SelectionStrategy = "NewestBuild"
	// SelectionStrategySemVer represents an image selection strategy that is
	// useful for finding the images referenced by the tag is the highest among
	// tags from the repository that are valid semantic versions. An optional
	// constraint can limit the eligible range of semantic versions.
	SelectionStrategySemVer SelectionStrategy = "SemVer"
)

type Selector added in v0.4.0

type Selector interface {
	// Select selects a single image from a container image repository.
	Select(context.Context) ([]Image, error)
}

Selector is an interface for selecting images from a container image repository.

func NewSelector added in v0.4.0

func NewSelector(
	repoURL string,
	strategy SelectionStrategy,
	opts *SelectorOptions,
) (Selector, error)

NewSelector returns some implementation of the Selector interface that selects a single image from a container image repository based on a selection strategy and a set of optional constraints.

type SelectorOptions added in v0.4.0

type SelectorOptions struct {
	// StrictSemvers, when set to true, will cause applicable selectors to only
	// count tags as valid semantic versions if they contain ALL of the major,
	// minor, and patch version components.
	StrictSemvers bool
	// Constraint specifies selector-specific constraints on image selection.
	Constraint string
	// AllowRegex is an optional regular expression that can be used to constrain
	// image selection based on eligible tags.
	AllowRegex string

	// Ignore is an optional list of tags that should explicitly be ignored when
	// selecting an image.
	Ignore []string
	// Platform is an optional platform constraint. If specified, the selected
	// image must match the platform constraint or Selector implementations will
	// return nil.
	Platform string

	// Creds holds optional credentials for authenticating to the image
	// repository.
	Creds *Credentials
	// InsecureSkipTLSVerify is an optional flag, that if set to true, will
	// disable verification of the image repository's TLS certificate.
	InsecureSkipTLSVerify bool
	// DiscoveryLimit is an optional limit on the number of images that can be
	// discovered by the Selector. The limit is applied after filtering images
	// based on the AllowRegex and Ignore fields. If the limit is zero, all
	// discovered images will be returned.
	DiscoveryLimit int
	// contains filtered or unexported fields
}

SelectorOptions represents options for creating a Selector.

Jump to

Keyboard shortcuts

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