public static ImageArchiveManifest readManifest(InputStream inputStream) throws IOException, JsonParseException {
        Map<String, JsonParseException> parseExceptions = new LinkedHashMap<>();
        Map<String, JsonElement> parsedEntries = new LinkedHashMap<>();

        try (TarArchiveInputStream tarStream = new TarArchiveInputStream(createUncompressedStream(inputStream))) {
            TarArchiveEntry tarEntry;
            Gson gson = new Gson();

            while((tarEntry = tarStream.getNextTarEntry()) != null) {
                if(tarEntry.isFile() && tarEntry.getName().endsWith(".json")) {
                    try {
                        JsonElement element = gson.fromJson(new InputStreamReader(tarStream, StandardCharsets.UTF_8), JsonElement.class);
                        parsedEntries.put(tarEntry.getName(), element);
                    } catch(JsonParseException exception) {
                        parseExceptions.put(tarEntry.getName(), exception);
                    }
                }
            }
        }

        JsonElement manifestJson = parsedEntries.get(MANIFEST_JSON);
        if(manifestJson == null) {
            JsonParseException parseException = parseExceptions.get(MANIFEST_JSON);
            if(parseException != null) {
                throw parseException;
            }

            return null;
        }

        ImageArchiveManifestAdapter manifest = new ImageArchiveManifestAdapter(manifestJson);

        for(ImageArchiveManifestEntry entry : manifest.getEntries()) {
            JsonElement entryConfigJson = parsedEntries.get(entry.getConfig());
            if(entryConfigJson != null && entryConfigJson.isJsonObject()) {
                manifest.putConfig(entry.getConfig(), entryConfigJson.getAsJsonObject());
            }
        }

        return manifest;
    }
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.

@param inputStream
@return the parsed manifest, or null if none found.
@throws IOException
@throws JsonParseException
src/main/java/io/fabric8/maven/docker/util/ImageArchiveUtil.java