public class ImageReference extends Object
| Modifier and Type | Method and Description |
|---|---|
String |
getRegistry()
Gets the registry portion of the
ImageReference. |
String |
getRepository()
Gets the repository portion of the
ImageReference. |
String |
getTag()
Gets the tag portion of the
ImageReference. |
static boolean |
isDefaultTag(String tag)
Returns
true if tag is the default tag ((@code latest} or empty); false
if not. |
boolean |
isTagDigest()
|
static boolean |
isValidRegistry(String registry)
Returns
true if registry is a valid registry string. |
static boolean |
isValidRepository(String repository)
Returns
true if repository is a valid repository string. |
static boolean |
isValidTag(String tag)
Returns
true if tag is a valid tag string. |
static ImageReference |
of(String registry,
String repository,
String tag)
Constructs an
ImageReference from the image reference components, consisting of an
optional registry, a repository, and an optional tag. |
static ImageReference |
parse(String reference)
Parses a string
reference into an ImageReference. |
String |
toString()
Stringifies the
ImageReference. |
String |
toStringWithTag()
Stringifies the
ImageReference, without hiding the tag. |
boolean |
usesDefaultTag()
|
ImageReference |
withTag(String newTag)
Gets an
ImageReference with the same registry and repository, but a different tag. |
public static ImageReference parse(String reference) throws InvalidImageReferenceException
reference into an ImageReference.
Image references should generally be in the form: <registry>/<repository>:<tag> For
example, an image reference could be gcr.io/distroless/java:debug.
See https://docs.docker.com/engine/reference/commandline/tag/#extended-description
for a description of valid image reference format. Note, however, that the image reference is
referred confusingly as tag on that page.
reference - the string to parseImageReference parsed from the stringInvalidImageReferenceException - if reference is formatted incorrectlypublic static ImageReference of(@Nullable String registry, String repository, @Nullable String tag)
ImageReference from the image reference components, consisting of an
optional registry, a repository, and an optional tag.registry - the image registry, or null to use the default registry (Docker Hub)repository - the image repositorytag - the image tag, or null to use the default tag (latest)ImageReference built from the given registry, repository, and tagpublic static boolean isValidRegistry(String registry)
true if registry is a valid registry string. For example, a valid
registry could be gcr.io or localhost:5000.registry - the registry to checktrue if is a valid registry; false otherwisepublic static boolean isValidRepository(String repository)
true if repository is a valid repository string. For example, a valid
repository could be distroless or my/container-image/repository.repository - the repository to checktrue if is a valid repository; false otherwisepublic static boolean isValidTag(String tag)
true if tag is a valid tag string. For example, a valid tag could be
v120.5-release.tag - the tag to checktrue if is a valid tag; false otherwisepublic static boolean isDefaultTag(String tag)
true if tag is the default tag ((@code latest} or empty); false
if not.tag - the tag to checktrue if tag is the default tag ((@code latest} or empty); false
if notpublic String getRegistry()
ImageReference.public String getRepository()
ImageReference.public String getTag()
ImageReference.public boolean usesDefaultTag()
true if uses the default tag; false if notpublic boolean isTagDigest()
true if tag is a SHA-256 digest; false if notpublic ImageReference withTag(String newTag)
ImageReference with the same registry and repository, but a different tag.newTag - the new tagImageReference with the same registry/repository and the new tagpublic String toString()
ImageReference. When the tag is a digest, it is prepended with the at
@ symbol instead of a colon :.toString in class Objectparse(java.lang.String))public String toStringWithTag()
ImageReference, without hiding the tag.Copyright © 2018. All rights reserved.