Class DockerFingerprints


  • public class DockerFingerprints
    extends Object
    Entry point into fingerprint related functionalities in Docker. This class provide basic methods for both images and containers
    • Method Detail

      • getFingerprintHash

        @NonNull
        public static String getFingerprintHash​(@NonNull
                                                String id)
        Gets a fingerprint hash for Docker ID (image or container). This method calculates image hash without retrieving a fingerprint by of(java.lang.String), which may be a high-cost call.
        Parameters:
        id - Docker ID (image or container). Only 64-char full IDs are supported.
        Returns:
        32-char fingerprint hash
        Throws:
        IllegalArgumentException - Invalid ID
      • of

        @CheckForNull
        public static Fingerprint of​(@NonNull
                                     String id)
                              throws IOException
        Gets Fingerprint for a given docker ID.
        Parameters:
        id - Docker ID (image or container). Only 64-char full IDs are supported.
        Returns:
        Created fingerprint or null if it is not found
        Throws:
        IOException - Fingerprint loading error
      • forImage

        @NonNull
        public static Fingerprint forImage​(@CheckForNull
                                           Run<?,​?> run,
                                           @NonNull
                                           String id,
                                           @CheckForNull
                                           String name)
                                    throws IOException
        Get or create a Fingerprint for the image.
        Parameters:
        run - Origin of the fingerprint (if available)
        id - Image ID. Only 64-char full IDs are supported.
        name - Optional name of the image. If null, the image name will be constructed using the specified ID.
        Returns:
        Fingerprint for the specified ID
        Throws:
        IOException - Fingerprint load/save error
        Since:
        TODO
      • forContainer

        @NonNull
        public static Fingerprint forContainer​(@CheckForNull
                                               Run<?,​?> run,
                                               @NonNull
                                               String id,
                                               @CheckForNull
                                               String name)
                                        throws IOException
        Get or create a Fingerprint for the container.
        Parameters:
        run - Origin of the fingerprint (if available)
        id - Container ID. Only 64-char full IDs are supported.
        name - Optional name of the container. If null, the container name will be constructed using the specified ID.
        Returns:
        Fingerprint for the specified ID
        Throws:
        IOException - Fingerprint load/save error
        Since:
        TODO
      • getFacet

        @CheckForNull
        public static <TFacet extends FingerprintFacet> TFacet getFacet​(@NonNull
                                                                        String id,
                                                                        @NonNull
                                                                        Class<TFacet> facetClass)
        Retrieves a facet from the Fingerprint. The method suppresses IOException if a fingerprint loading fails.
        Type Parameters:
        TFacet - Facet type to be retrieved
        Parameters:
        id - Docker item ID. Only 64-char full IDs are supported
        facetClass - Class to be retrieved
        Returns:
        First matching facet. Null may be returned if there is no facet or if the loading fails
      • getFacets

        @NonNull
        public static <TFacet extends FingerprintFacetCollection<TFacet> getFacets​(@NonNull
                                                                                     String id,
                                                                                     @NonNull
                                                                                     Class<TFacet> facetClass)
        Retrieves a facet from the Fingerprint. The method suppresses IOException if a fingerprint loading fails.
        Type Parameters:
        TFacet - Facet type to be retrieved
        Parameters:
        id - Docker item ID. Only 64-char full IDs are supported
        facetClass - Class to be retrieved
        Returns:
        First matching facet. Null may be returned if the loading fails
      • getFacet

        @CheckForNull
        public static <TFacet extends FingerprintFacet> TFacet getFacet​(@NonNull
                                                                        Fingerprint fingerprint,
                                                                        @NonNull
                                                                        Class<TFacet> facetClass)
        Retrieves a facet from the Fingerprint.
        Type Parameters:
        TFacet - Facet type to be retrieved
        Parameters:
        fingerprint - Fingerprint, which stores facets
        facetClass - Class to be retrieved
        Returns:
        First matching facet.
      • getFacets

        @NonNull
        public static <TFacet extends FingerprintFacetCollection<TFacet> getFacets​(@NonNull
                                                                                     Fingerprint fingerprint,
                                                                                     @NonNull
                                                                                     Class<TFacet> facetClass)
        Retrieves facets from the Fingerprint.
        Type Parameters:
        TFacet - Facet type to be retrieved
        Parameters:
        fingerprint - Fingerprint, which stores facets
        facetClass - Facet class to be retrieved
        Returns:
        All found facets
      • addFromFacet

        public static void addFromFacet​(@CheckForNull
                                        String ancestorImageId,
                                        @NonNull
                                        String descendantImageId,
                                        @NonNull
                                        Run<?,​?> run)
                                 throws IOException
        Creates a new DockerAncestorFingerprintFacet and DockerDescendantFingerprintFacet and adds a run. Or adds to existing facets.
        Parameters:
        ancestorImageId - the ID of the image specified in a FROM instruction, or null in case of scratch (i.e., the descendant is a base image)
        descendantImageId - the ID of the image which was built
        run - the build in which the image building occurred
        Throws:
        IOException