Class ImageReference

    • Method Detail

      • of

        public static ImageReference of​(@Nullable
                                        java.lang.String registry,
                                        java.lang.String repository,
                                        @Nullable
                                        java.lang.String qualifier)
        Constructs an ImageReference from the image reference components, consisting of an optional registry, a repository, and an optional tag.
        Parameters:
        registry - the image registry, or null to use the default registry (Docker Hub)
        repository - the image repository
        qualifier - the image tag or digest, or null to use the default tag ( latest).
        Returns:
        an ImageReference built from the given registry, repository, and tag
      • of

        public static ImageReference of​(@Nullable
                                        java.lang.String registry,
                                        java.lang.String repository,
                                        @Nullable
                                        java.lang.String tag,
                                        @Nullable
                                        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. If neither the tag nor digest are specified, tag will take on the default value of latest.
        Parameters:
        registry - the image registry, or null to use the default registry (Docker Hub)
        repository - the image repository
        tag - the image tag, or null to use the default tag (latest)
        digest - the image digest
        Returns:
        an ImageReference built from the given registry, repository, and tag
      • scratch

        public static ImageReference scratch()
        Constructs an ImageReference with an empty registry and tag component, and repository set to "scratch".
        Returns:
        an ImageReference with an empty registry and tag component, and repository set to "scratch"
      • isValidRegistry

        public static boolean isValidRegistry​(java.lang.String registry)
        Returns true if registry is a valid registry string. For example, a valid registry could be gcr.io or localhost:5000.
        Parameters:
        registry - the registry to check
        Returns:
        true if is a valid registry; false otherwise
      • isValidRepository

        public static boolean isValidRepository​(java.lang.String repository)
        Returns true if repository is a valid repository string. For example, a valid repository string could be my-repository or k8s-skaffold/skaffold.
        Parameters:
        repository - the repository to check
        Returns:
        true if is a valid repository; false otherwise
      • isValidTag

        public static boolean isValidTag​(java.lang.String tag)
        Returns true if tag is a valid tag string. For example, a valid tag could be v120.5-release.
        Parameters:
        tag - the tag to check
        Returns:
        true if is a valid tag; false otherwise
      • isValidDigest

        public static boolean isValidDigest​(java.lang.String digest)
        Returns true if digest is a valid digest string. For example, a valid digest could be sha256:868fd30a0e47b8d8ac485df174795b5e2fe8a6c8f056cc707b232d65b8a1ab68.
        Parameters:
        digest - the digest to check
        Returns:
        true if is a valid digest; false otherwise
      • isDefaultTag

        public static boolean isDefaultTag​(@Nullable
                                           java.lang.String tag)
        Returns true if tag is the default tag (latest); false if not.
        Parameters:
        tag - the tag to check
        Returns:
        true if tag is the default tag (latest); false if not
      • getRegistry

        public java.lang.String getRegistry()
        Gets the registry portion of the ImageReference.
        Returns:
        the registry host
      • getRepository

        public java.lang.String getRepository()
        Gets the repository portion of the ImageReference.
        Returns:
        the repository
      • getTag

        public java.util.Optional<java.lang.String> getTag()
        Gets the tag portion of the ImageReference.
        Returns:
        the optional tag
      • getDigest

        public java.util.Optional<java.lang.String> getDigest()
        Gets the digest portion of the ImageReference.
        Returns:
        the optional digest
      • getQualifier

        public java.lang.String getQualifier()
        Gets the digest portion of the ImageReference if set, else returns the tag.
        Returns:
        the digest if set, else the tag
      • usesDefaultTag

        public boolean usesDefaultTag()
        Returns true if the ImageReference uses the default tag (latest); false if not.
        Returns:
        true if uses the default tag; false if not
      • isScratch

        public boolean isScratch()
        Returns true if the ImageReference is a scratch image; false if not.
        Returns:
        true if the ImageReference is a scratch image; false if not
      • withQualifier

        public ImageReference withQualifier​(java.lang.String newQualifier)
        Gets an ImageReference with the same registry and repository, but a different tag or digest.
        Parameters:
        newQualifier - the new tag or digest
        Returns:
        an ImageReference with the same registry/repository and the new tag or digest
      • toString

        public java.lang.String toString()
        Stringifies the ImageReference.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the image reference in Docker-readable format (inverse of parse(java.lang.String))
      • toStringWithQualifier

        public java.lang.String toStringWithQualifier()
        Stringifies the 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.
        Returns:
        the image reference in Docker-readable format including a qualifier.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object