Class ImageArchiveUtil


  • public class ImageArchiveUtil
    extends Object
    Helper functions for working with Docker image archives, as produced by the docker:save mojo.
    • Constructor Detail

      • ImageArchiveUtil

        public ImageArchiveUtil()
    • Method Detail

      • readManifest

        public static ImageArchiveManifest readManifest​(File file)
                                                 throws IOException,
                                                        com.google.gson.JsonParseException
        Read the (possibly compressed) image archive provided and return the archive manifest. If there is no manifest found, then null is returned. Incomplete manifests are returned with as much information parsed as possible.
        Parameters:
        file -
        Returns:
        the parsed manifest, or null if none found.
        Throws:
        IOException
        com.google.gson.JsonParseException
      • readManifest

        public static ImageArchiveManifest readManifest​(InputStream inputStream)
                                                 throws IOException,
                                                        com.google.gson.JsonParseException
        Read the (possibly compressed) image archive stream provided and return the archive manifest. If there is no manifest found, then null is returned. Incomplete manifests are returned with as much information parsed as possible.
        Parameters:
        inputStream -
        Returns:
        the parsed manifest, or null if none found.
        Throws:
        IOException
        com.google.gson.JsonParseException
      • findEntryByRepoTag

        public static ImageArchiveManifestEntry findEntryByRepoTag​(String repoTag,
                                                                   ImageArchiveManifest manifest)
        Search the manifest for an entry that has the repository and tag provided.
        Parameters:
        repoTag - the repository and tag to search (e.g. busybox:latest).
        manifest - the manifest to be searched
        Returns:
        the entry found, or null if no match.
      • findEntryByRepoTagPattern

        public static org.apache.commons.lang3.tuple.Pair<String,​ImageArchiveManifestEntry> findEntryByRepoTagPattern​(String repoTagPattern,
                                                                                                                            ImageArchiveManifest manifest)
                                                                                                                     throws PatternSyntaxException
        Search the manifest for an entry that has a repository and tag matching the provided pattern.
        Parameters:
        repoTagPattern - the repository and tag to search (e.g. busybox:latest).
        manifest - the manifest to be searched
        Returns:
        a pair containing the matched tag and the entry found, or null if no match.
        Throws:
        PatternSyntaxException
      • findEntryByRepoTagPattern

        public static org.apache.commons.lang3.tuple.Pair<String,​ImageArchiveManifestEntry> findEntryByRepoTagPattern​(Pattern repoTagPattern,
                                                                                                                            ImageArchiveManifest manifest)
                                                                                                                     throws PatternSyntaxException
        Search the manifest for an entry that has a repository and tag matching the provided pattern.
        Parameters:
        repoTagPattern - the repository and tag to search (e.g. busybox:latest).
        manifest - the manifest to be searched
        Returns:
        a pair containing the matched tag and the entry found, or null if no match.
        Throws:
        PatternSyntaxException
      • findEntriesByRepoTagPattern

        public static Map<String,​ImageArchiveManifestEntry> findEntriesByRepoTagPattern​(String repoTagPattern,
                                                                                              ImageArchiveManifest manifest)
                                                                                       throws PatternSyntaxException
        Search the manifest for an entry that has a repository and tag matching the provided pattern.
        Parameters:
        repoTagPattern - the repository and tag to search (e.g. busybox:latest).
        manifest - the manifest to be searched
        Returns:
        a pair containing the matched tag and the entry found, or null if no match.
        Throws:
        PatternSyntaxException
      • findEntriesByRepoTagPattern

        public static Map<String,​ImageArchiveManifestEntry> findEntriesByRepoTagPattern​(Pattern repoTagPattern,
                                                                                              ImageArchiveManifest manifest)
                                                                                       throws PatternSyntaxException
        Search the manifest for an entry that has a repository and tag matching the provided pattern.
        Parameters:
        repoTagPattern - the repository and tag to search (e.g. busybox:latest).
        manifest - the manifest to be searched
        Returns:
        a pair containing the matched tag and the entry found, or null if no match.
        Throws:
        PatternSyntaxException