java.lang.Object
org.springframework.boot.buildpack.platform.docker.type.ImageReference

public final class ImageReference extends Object
A reference to a Docker image of the form "imagename[:tag|@digest]".
Since:
2.3.0
Author:
Phillip Webb, Scott Frederick
See Also:
  • Method Details

    • getDomain

      public String getDomain()
      Return the domain for this image name.
      Returns:
      the domain
      See Also:
    • getName

      public String getName()
      Return the name of this image.
      Returns:
      the image name
      See Also:
    • getTag

      public String getTag()
      Return the tag from the reference or null.
      Returns:
      the referenced tag
    • getDigest

      public String getDigest()
      Return the digest from the reference or null.
      Returns:
      the referenced digest
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toLegacyString

      public String toLegacyString()
    • withDigest

      public ImageReference withDigest(String digest)
      Create a new ImageReference with an updated digest.
      Parameters:
      digest - the new digest
      Returns:
      an updated image reference
    • inTaggedForm

      public ImageReference inTaggedForm()
      Return an ImageReference in the form "imagename:tag". If the tag has not been defined then latest is used.
      Returns:
      the image reference in tagged form
      Throws:
      IllegalStateException - if the image reference contains a digest
    • inTaggedOrDigestForm

      public ImageReference inTaggedOrDigestForm()
      Return an ImageReference containing either a tag or a digest. If neither the digest nor the tag has been defined then tag latest is used.
      Returns:
      the image reference in tagged or digest form
    • forJarFile

      public static ImageReference forJarFile(File jarFile)
      Create a new ImageReference instance deduced from a source JAR file that follows common Java naming conventions.
      Parameters:
      jarFile - the source jar file
      Returns:
      an ImageName for the jar file.
    • random

      public static ImageReference random(String prefix)
      Generate an image name with a random suffix.
      Parameters:
      prefix - the name prefix
      Returns:
      a random image reference
    • random

      public static ImageReference random(String prefix, int randomLength)
      Generate an image name with a random suffix.
      Parameters:
      prefix - the name prefix
      randomLength - the number of chars in the random part of the name
      Returns:
      a random image reference
    • of

      public static ImageReference of(String value)
      Create a new ImageReference from the given value. The following value forms can be used:
      • name (maps to docker.io/library/name)
      • domain/name
      • domain:port/name
      • domain:port/name:tag
      • domain:port/[email protected]
      Parameters:
      value - the value to parse
      Returns:
      an ImageName instance
    • of

      public static ImageReference of(ImageName name)
      Create a new ImageReference from the given ImageName.
      Parameters:
      name - the image name
      Returns:
      a new image reference
    • of

      public static ImageReference of(ImageName name, String tag)
      Create a new ImageReference from the given ImageName and tag.
      Parameters:
      name - the image name
      tag - the referenced tag
      Returns:
      a new image reference
    • of

      public static ImageReference of(ImageName name, String tag, String digest)
      Create a new ImageReference from the given ImageName, tag and digest.
      Parameters:
      name - the image name
      tag - the referenced tag
      digest - the referenced digest
      Returns:
      a new image reference