imageutil

package
v0.0.0-...-eb2f24c Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 306

Documentation

Index

Constants

View Source
const (
	// DefaultImageTag is used when an image tag is needed and the configuration does not specify a tag to use.
	DefaultImageTag = "latest"
)

Variables

View Source
var (
	// ErrNoStreamRepository is returned if the status dockerImageRepository field was unset but the
	// method required that value to create a pull spec.
	ErrNoStreamRepository = fmt.Errorf("no image repository has been set on the image stream status")
	// ErrWaitForPullSpec is returned when a pull spec cannot be inferred from the image stream automatically
	// and the user requires a valid image tag.
	ErrWaitForPullSpec = fmt.Errorf("the pull spec cannot be determined yet")
)

Functions

func DigestOrImageMatch

func DigestOrImageMatch(image, imageID string) bool

DigestOrImageMatch matches the digest in the image name.

func ImageWithMetadata

func ImageWithMetadata(image *imagev1.Image) error

ImageWithMetadata mutates the given image. It parses raw DockerImageManifest data stored in the image and fills its DockerImageMetadata and other fields. Copied from github.com/openshift/image-registry/pkg/origin-common/util/util.go

func ImageWithMetadataOrDie

func ImageWithMetadataOrDie(image *imagev1.Image)

func JoinImageStreamImage

func JoinImageStreamImage(name, id string) string

JoinImageStreamImage creates a name for image stream image object from an image stream name and an id.

func JoinImageStreamTag

func JoinImageStreamTag(name, tag string) string

JoinImageStreamTag turns a name and tag into the name of an ImageStreamTag

func LatestTaggedImage

func LatestTaggedImage(stream *imagev1.ImageStream, tag string) *imagev1.TagEvent

LatestTaggedImage returns the most recent TagEvent for the specified image repository and tag. Will resolve lookups for the empty tag. Returns nil if tag isn't present in stream.status.tags.

func ParseDockerImageReference

func ParseDockerImageReference(spec string) (imagev1.DockerImageReference, error)

ParseDockerImageReference parses a Docker pull spec string into a DockerImageReference.

func ParseImageStreamImageName

func ParseImageStreamImageName(input string) (name string, id string, err error)

ParseImageStreamImageName splits a string into its name component and ID component, and returns an error if the string is not in the right form.

func ParseImageStreamTagName

func ParseImageStreamTagName(istag string) (name string, tag string, err error)

ParseImageStreamTagName splits a string into its name component and tag component, and returns an error if the string is not in the right form.

func PrioritizeTags

func PrioritizeTags(tags []string)

PrioritizeTags orders a set of image tags with a few conventions:

1. the "latest" tag, if present, should be first 2. any tags that represent a semantic minor version ("5.1", "v5.1", "v5.1-rc1") should be next, in descending order 3. any tags that represent a full semantic version ("5.1.3-other", "v5.1.3-other") should be next, in descending order 4. any remaining tags should be sorted in lexicographic order

The method updates the tags in place.

func ResolveLatestTaggedImage

func ResolveLatestTaggedImage(stream *imagev1.ImageStream, tag string) (string, bool)

ResolveLatestTaggedImage returns the appropriate pull spec for a given tag in the image stream, handling the tag's reference policy if necessary to return a resolved image. Callers that transform an ImageStreamTag into a pull spec should use this method instead of LatestTaggedImage. This method ignores pending imports (meaning the requested image may be stale) and will return no pull spec even if one is available on the spec tag (when importing kind DockerImage) if import has not completed.

Use ResolvePullSpecForTag() if you wish more control over what type of pull spec is returned and what scenarios should be handled.

func ResolveNewestPullSpecForTag

func ResolveNewestPullSpecForTag(stream *imagev1.ImageStream, tag string, defaultExternal bool) (pullSpec string, hasStatus, isTagEmpty bool, err error)

ResolveNewestPullSpecForTag returns the most recent available pull spec for the given tag, even if importing that pull spec is still in progress or has failed. Use this method when the current state of the tag as the user sees it is important because you don't want to silently ignore a newer tag request that hasn't yet been imported. Note that if no image has been tagged or pushed, pullSpec will still be returned pointing to the pull spec for the tag within the image repository (<status.dockerImageRepository>:<tag> unless defaultExternal is set) and isTagEmpty will be true. hasStatus is true if the returned pull spec points to an imported / pushed image, or false if a spec tag has not been specified, the spec tag hasn't been imported, or the import has failed. An error is returned only if isTagEmpty is true and status.dockerImageRepository is unset because the administrator has not installed a registry server.

Use this method when you need the user intent pull spec and you do not want to tolerate a slightly older image (tooling that needs to error if the user's intent in tagging isn't realized).

func ResolveRecentPullSpecForTag

func ResolveRecentPullSpecForTag(stream *imagev1.ImageStream, tag string, defaultExternal bool) (pullSpec string, hasNewer, hasStatus, isTagEmpty bool, err error)

ResolveRecentPullSpecForTag returns the most recent successfully imported pull sec for the given tag, i.e. "last-known-good". Use this method when you can tolerate some lag in picking up the newest version. This method is roughly equivalent to the behavior of pulling the pod from the internal registry. If no image has been tagged or pushed, pullSpec will still be returned pointing to the pull spec for the tag within the image repository (<status.dockerImageRepository>:<tag> unless defaultExternal is set) and isTagEmpty will be true. hasNewer is true if the pull spec does not represent the newest user input, or false if the current user spec tag has been imported successfully. hasStatus is true if the returned pull spec points to an imported / pushed image, or false if a spec tag has not been specified, the spec tag hasn't been imported, or the import has failed. An error is returned only if isTagEmpty is true and status.dockerImageRepository is unset because the administrator has not installed a registry server.

This method is typically used by consumers that need the value at the tag and prefer to have a slightly older image over not getting any image at all (or if the image can't be imported due to temporary network or controller issues).

func SpecHasTag

func SpecHasTag(stream *imagev1.ImageStream, name string) (imagev1.TagReference, bool)

SpecHasTag returns named tag from image stream's spec and boolean whether one was found.

func SplitImageStreamImage

func SplitImageStreamImage(nameAndID string) (name string, id string, ok bool)

SplitImageStreamImage turns the name of an ImageStreamImage into Name and ID. It returns false if the ID was not properly specified in the name.

func SplitImageStreamTag

func SplitImageStreamTag(nameAndTag string) (name string, tag string, ok bool)

SplitImageStreamTag turns the name of an ImageStreamTag into Name and Tag. It returns false if the tag was not properly specified in the name.

func StatusHasTag

func StatusHasTag(stream *imagev1.ImageStream, name string) (imagev1.NamedTagEventList, bool)

StatusHasTag returns named tag from image stream's status and boolean whether one was found.

func TagReferencesLocalTag

func TagReferencesLocalTag(stream *imagev1.ImageStream, tag imagev1.TagReference) (string, bool)

TagReferencesLocalTag returns true if the provided tag reference references another image stream tag in the current image stream. This is only true when from points to an ImageStreamTag without a colon or from.name is <streamName>:<tag>.

Types

This section is empty.

Jump to

Keyboard shortcuts

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