diff options
author | ralph isenmann | 2022-01-28 12:36:06 +0100 |
---|---|---|
committer | ralph isenmann | 2022-01-28 12:36:06 +0100 |
commit | f12867fbef875a8e439ae80a00a6464a52cebcff (patch) | |
tree | 67d006dae9b96b191398b14218dacb34bf902a72 /dozentenmodul/src/main/java | |
parent | [CLIENT,SERVER] move handling of tar into TarArchiveReader and TarArchiveWrit... (diff) | |
download | tutor-module-f12867fbef875a8e439ae80a00a6464a52cebcff.tar.gz tutor-module-f12867fbef875a8e439ae80a00a6464a52cebcff.tar.xz tutor-module-f12867fbef875a8e439ae80a00a6464a52cebcff.zip |
[CLIENT] fix valid check for docker-archive without repotag
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java | 21 |
1 files changed, 15 insertions, 6 deletions
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; } |