Class DockerFingerprints
java.lang.Object
org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints
Entry point into fingerprint related functionalities in Docker.
This class provide basic methods for both images and containers
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddFromFacet(String ancestorImageId, String descendantImageId, Run<?, ?> run) Creates a newDockerAncestorFingerprintFacetandDockerDescendantFingerprintFacetand adds a run.static voidaddRunFacet(ContainerRecord record, Run<?, ?> run) Adds a newContainerRecordfor the specified image, creating necessary intermediate objects as it goes.static FingerprintforContainer(Run<?, ?> run, String id) Deprecated.static FingerprintforContainer(Run<?, ?> run, String id, String name) Get or create aFingerprintfor the container.static FingerprintDeprecated.static FingerprintGet or create aFingerprintfor the image.static <TFacet extends FingerprintFacet>
TFacetgetFacet(Fingerprint fingerprint, Class<TFacet> facetClass) Retrieves a facet from theFingerprint.static <TFacet extends FingerprintFacet>
TFacetRetrieves a facet from theFingerprint.static <TFacet extends FingerprintFacet>
Collection<TFacet>getFacets(Fingerprint fingerprint, Class<TFacet> facetClass) Retrieves facets from theFingerprint.static <TFacet extends FingerprintFacet>
Collection<TFacet>Retrieves a facet from theFingerprint.static StringGets a fingerprint hash for Docker ID (image or container).static FingerprintGetsFingerprintfor a given docker ID.
-
Method Details
-
getFingerprintHash
Gets a fingerprint hash for Docker ID (image or container). This method calculates image hash without retrieving a fingerprint byof(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
GetsFingerprintfor 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) throws IOExceptionDeprecated.- Throws:
IOException
-
forImage
@NonNull public static Fingerprint forImage(@CheckForNull Run<?, ?> run, @NonNull String id, @CheckForNull String name) throws IOExceptionGet or create aFingerprintfor 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
@Deprecated @NonNull public static Fingerprint forContainer(@CheckForNull Run<?, ?> run, @NonNull String id) throws IOException- Throws:
IOException
-
forContainer
@NonNull public static Fingerprint forContainer(@CheckForNull Run<?, ?> run, @NonNull String id, @CheckForNull String name) throws IOExceptionGet or create aFingerprintfor 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 theFingerprint. The method suppressesIOExceptionif a fingerprint loading fails.- Type Parameters:
TFacet- Facet type to be retrieved- Parameters:
id- Docker item ID. Only 64-char full IDs are supportedfacetClass- 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 FingerprintFacet> Collection<TFacet> getFacets(@NonNull String id, @NonNull Class<TFacet> facetClass) Retrieves a facet from theFingerprint. The method suppressesIOExceptionif a fingerprint loading fails.- Type Parameters:
TFacet- Facet type to be retrieved- Parameters:
id- Docker item ID. Only 64-char full IDs are supportedfacetClass- 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 theFingerprint.- Type Parameters:
TFacet- Facet type to be retrieved- Parameters:
fingerprint- Fingerprint, which stores facetsfacetClass- Class to be retrieved- Returns:
- First matching facet.
-
getFacets
@NonNull public static <TFacet extends FingerprintFacet> Collection<TFacet> getFacets(@NonNull Fingerprint fingerprint, @NonNull Class<TFacet> facetClass) Retrieves facets from theFingerprint.- Type Parameters:
TFacet- Facet type to be retrieved- Parameters:
fingerprint- Fingerprint, which stores facetsfacetClass- Facet class to be retrieved- Returns:
- All found facets
-
addRunFacet
public static void addRunFacet(@NonNull ContainerRecord record, @NonNull Run<?, ?> run) throws IOExceptionAdds a newContainerRecordfor the specified image, creating necessary intermediate objects as it goes.- Throws:
IOException
-
addFromFacet
public static void addFromFacet(@CheckForNull String ancestorImageId, @NonNull String descendantImageId, @NonNull Run<?, ?> run) throws IOExceptionCreates a newDockerAncestorFingerprintFacetandDockerDescendantFingerprintFacetand adds a run. Or adds to existing facets.- Parameters:
ancestorImageId- the ID of the image specified in aFROMinstruction, or null in case ofscratch(i.e., the descendant is a base image)descendantImageId- the ID of the image which was builtrun- the build in which the image building occurred- Throws:
IOException
-
forContainer(hudson.model.Run, java.lang.String, java.lang.String)