From f12867fbef875a8e439ae80a00a6464a52cebcff Mon Sep 17 00:00:00 2001 From: ralph isenmann Date: Fri, 28 Jan 2022 12:36:06 +0100 Subject: [CLIENT] fix valid check for docker-archive without repotag --- .../org/openslx/dozmod/util/ContainerUtils.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'dozentenmodul/src') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java index 783fb0fa..7ec6ef13 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java @@ -141,20 +141,29 @@ public class ContainerUtils { } Util.safeClose(tarReader); - // check the json files inside the tar file + } catch (IOException e) { + LOGGER.error("IOError while processing tar file", e); + } + + // check the json files inside the tar file + try { + if (containsManifest && containsRepositories && manifestJson.isJsonArray() && manifestJson.size() == 1) { isValid = true; - String repoTag = manifestJson.get(0).getAsJsonObject().get("RepoTags").getAsString(); - LOGGER.info(String.format("Tar File contains Docker Image with repoTag=%s", repoTag)); + JsonArray jRepoTags = manifestJson.get(0).getAsJsonObject().getAsJsonArray("RepoTags"); + if (jRepoTags.isEmpty()) + LOGGER.info("Valid Docker-Archive with no repoTags recognized"); + else + LOGGER.info(String.format("Valid Docker-Archive with repoTag=%s recognized", jRepoTags.get(0).toString())); } else if (containsManifest && containsRepositories && manifestJson.isJsonArray() && manifestJson.size() > 1) { Gui.showMessageBox("Tar File container more then one Images!", MessageType.ERROR, LOGGER, null); } else { Gui.showMessageBox("No valid Tar File with Images provided!", MessageType.ERROR, LOGGER, null); } - - } catch (IOException e) { - LOGGER.error("IOError while processing tar file", e); + } catch (IllegalStateException e) { + Gui.showMessageBox("An error occurred while checking the Docker archive!", MessageType.ERROR, LOGGER, null); + isValid=false; } return isValid; } -- cgit v1.2.3-55-g7522