public class ImageReference
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
java.util.Optional<java.lang.String> |
getDigest()
Gets the digest portion of the
ImageReference . |
java.lang.String |
getQualifier()
Gets the digest portion of the
ImageReference if set, else returns the tag. |
java.lang.String |
getRegistry()
Gets the registry portion of the
ImageReference . |
java.lang.String |
getRepository()
Gets the repository portion of the
ImageReference . |
java.util.Optional<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 (latest ); false if not. |
boolean |
isScratch()
|
static boolean |
isValidDigest(java.lang.String digest)
Returns
true if digest is a valid digest string. |
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 qualifier)
Constructs an
ImageReference from the image reference components, consisting of an
optional registry, a repository, and an optional tag. |
static ImageReference |
of(java.lang.String registry,
java.lang.String repository,
java.lang.String tag,
java.lang.String digest)
Constructs an
ImageReference from the image reference components, consisting of an
optional registry, a repository, an optional tag, and an optional digest. |
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 |
toStringWithQualifier()
Stringifies the
ImageReference . |
boolean |
usesDefaultTag()
|
ImageReference |
withQualifier(java.lang.String newQualifier)
Gets an
ImageReference with the same registry and repository, but a different tag or
digest. |
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/k8s-skaffold/skaffold:v1.20.0
.
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 qualifier)
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 repositoryqualifier
- the image tag or digest, or null
to use the default tag (latest
).ImageReference
built from the given registry, repository, and tagpublic static ImageReference of(@Nullable java.lang.String registry, java.lang.String repository, @Nullable java.lang.String tag, @Nullable java.lang.String digest)
ImageReference
from the image reference components, consisting of an
optional registry, a repository, an optional tag, and an optional digest. If neither the tag
nor digest are specified, tag
will take on the default value of latest
.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
)digest
- the image digestImageReference
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 string could be my-repository
or k8s-skaffold/skaffold
.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 isValidDigest(java.lang.String digest)
true
if digest
is a valid digest string. For example, a valid digest
could be sha256:868fd30a0e47b8d8ac485df174795b5e2fe8a6c8f056cc707b232d65b8a1ab68
.digest
- the digest to checktrue
if is a valid digest; false
otherwisepublic static boolean isDefaultTag(@Nullable java.lang.String tag)
true
if tag
is the default tag (latest
); false
if not.tag
- the tag to checktrue
if tag
is the default tag (latest
); false
if notpublic java.lang.String getRegistry()
ImageReference
.public java.lang.String getRepository()
ImageReference
.public java.util.Optional<java.lang.String> getTag()
ImageReference
.public java.util.Optional<java.lang.String> getDigest()
ImageReference
.public java.lang.String getQualifier()
ImageReference
if set, else returns the tag.public boolean usesDefaultTag()
true
if uses the default tag; false
if notpublic boolean isScratch()
true
if the ImageReference
is a scratch image; false
if notpublic ImageReference withQualifier(java.lang.String newQualifier)
ImageReference
with the same registry and repository, but a different tag or
digest.newQualifier
- the new tag or digestImageReference
with the same registry/repository and the new tag or digestpublic java.lang.String toString()
ImageReference
.toString
in class java.lang.Object
parse(java.lang.String)
)public java.lang.String toStringWithQualifier()
ImageReference
. If the digest is set, the result will include the
digest and no tag. Otherwise, the result will include the tag, or latest
if no tag is
set.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object