public class ImageReference
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
java.lang.String |
getRegistry()
Gets the registry portion of the
ImageReference . |
java.lang.String |
getRepository()
Gets the repository portion of the
ImageReference . |
java.lang.String |
getTag()
Gets the tag portion of the
ImageReference . |
int |
hashCode() |
static boolean |
isDefaultTag(java.lang.String tag)
Returns
true if tag is the default tag ((@code latest} or empty); false
if not. |
boolean |
isScratch()
|
boolean |
isTagDigest()
|
static boolean |
isValidRegistry(java.lang.String registry)
Returns
true if registry is a valid registry string. |
static boolean |
isValidRepository(java.lang.String repository)
Returns
true if repository is a valid repository string. |
static boolean |
isValidTag(java.lang.String tag)
Returns
true if tag is a valid tag string. |
static ImageReference |
of(java.lang.String registry,
java.lang.String repository,
java.lang.String tag)
Constructs an
ImageReference from the image reference components, consisting of an
optional registry, a repository, and an optional tag. |
static ImageReference |
parse(java.lang.String reference)
Parses a string
reference into an ImageReference . |
static ImageReference |
scratch()
Constructs an
ImageReference with an empty registry and tag component, and repository
set to "scratch". |
java.lang.String |
toString()
Stringifies the
ImageReference . |
java.lang.String |
toStringWithTag()
Stringifies the
ImageReference , without hiding the tag. |
boolean |
usesDefaultTag()
|
ImageReference |
withTag(java.lang.String newTag)
Gets an
ImageReference with the same registry and repository, but a different tag. |
public static ImageReference parse(java.lang.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 java.lang.String registry, java.lang.String repository, @Nullable java.lang.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 ImageReference scratch()
ImageReference
with an empty registry and tag component, and repository
set to "scratch".ImageReference
with an empty registry and tag component, and repository set
to "scratch"public static boolean isValidRegistry(java.lang.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(java.lang.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(java.lang.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(java.lang.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 java.lang.String getRegistry()
ImageReference
.public java.lang.String getRepository()
ImageReference
.public java.lang.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 boolean isScratch()
true
if the ImageReference
is a scratch image; false
if notpublic ImageReference withTag(java.lang.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 java.lang.String toString()
ImageReference
. When the tag is a digest, it is prepended with the at
@
symbol instead of a colon :
.toString
in class java.lang.Object
parse(java.lang.String)
)public java.lang.String toStringWithTag()
ImageReference
, without hiding the tag.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object