diff options
author | ralph isenmann | 2021-10-15 16:31:17 +0200 |
---|---|---|
committer | ralph isenmann | 2021-10-15 16:31:17 +0200 |
commit | ec5150eb1cbc685a40add49ade667c9bae517cc3 (patch) | |
tree | f23b6e5fe8107ac8dff4ede14cd459d214f9f8d6 | |
parent | [client] Update process of the download for container images (diff) | |
download | tutor-module-ec5150eb1cbc685a40add49ade667c9bae517cc3.tar.gz tutor-module-ec5150eb1cbc685a40add49ade667c9bae517cc3.tar.xz tutor-module-ec5150eb1cbc685a40add49ade667c9bae517cc3.zip |
[client] refactoring: apply changes from master-sync-share
4 files changed, 25 insertions, 26 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java index 2ef10a48..d01b7200 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java @@ -125,17 +125,17 @@ public class ContainerPanel extends JPanel { txtContainerImageName.setText(image.imageName); txtContainerImageName.setEnabled(false); // TODO simplify this mess. ContainerBuildContextMethod is to complex or useless - switch (containerDefinition.getBuildContextMethod()) { - case FILE: + switch (containerDefinition.getContainerImageContext()) { + case DOCKERFILE: txtContainerRecipe.setText(containerDefinition.getContainerRecipe()); break; - case IMAGE_REPO: + case IMAGE_REPOSITORY: txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageRepo()); break; case GIT_REPOSITORY: txtContainerRecipe.setText(containerDefinition.getContainerMeta().getBuildContextUrl()); break; - case DOCKER_TAR: + case DOCKER_ARCHIVE: txtContainerRecipe.setText(containerDefinition.getContainerMeta().getImageName()); break; default: diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java index 509ba11e..2bc4c768 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java @@ -5,7 +5,7 @@ import org.openslx.dozmod.gui.helper.GridManager; import org.openslx.dozmod.gui.helper.I18n; import org.openslx.dozmod.gui.wizard.Wizard; import org.openslx.dozmod.gui.wizard.WizardPage; -import org.openslx.virtualization.configuration.container.ContainerBuildContextMethod; +import org.openslx.virtualization.configuration.container.ContainerImageContext; import javax.swing.*; import java.awt.*; @@ -44,7 +44,7 @@ public class ContainerUploadPageLayout extends WizardPage { // #################################### // Dockerfile Input Panel -- UNUSED -- - JPanel pnlDockerfileInput = new ContainerTabPanel(ContainerBuildContextMethod.FILE); + JPanel pnlDockerfileInput = new ContainerTabPanel(ContainerImageContext.DOCKERFILE); pnlDockerfileInput.setVisible(false); tmpGrid = new GridManager(pnlDockerfileInput, 3, true, new Insets(0, 5, 0, 5)); QLabel imageFileCaption = new QLabel( @@ -60,7 +60,7 @@ public class ContainerUploadPageLayout extends WizardPage { // #################################### // Git Repository Input Panel -- UNUSED -- - JPanel pnlGitRepositoryInput = new ContainerTabPanel(ContainerBuildContextMethod.GIT_REPOSITORY); + JPanel pnlGitRepositoryInput = new ContainerTabPanel(ContainerImageContext.GIT_REPOSITORY); pnlGitRepositoryInput.setVisible(false); tmpGrid = new GridManager(pnlGitRepositoryInput, 2, true, new Insets(0, 5, 0, 5)); QLabel lblGitRepo = new QLabel(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.GitRepository.label")); @@ -75,7 +75,7 @@ public class ContainerUploadPageLayout extends WizardPage { // #################################### // Container Archive Input Panel - JPanel pnlContainerImage = new ContainerTabPanel(ContainerBuildContextMethod.DOCKER_TAR); + JPanel pnlContainerImage = new ContainerTabPanel(ContainerImageContext.DOCKER_ARCHIVE); pnlGitRepositoryInput.setVisible(false); tmpGrid = new GridManager(pnlContainerImage, 3, true, new Insets(0, 5, 0, 5)); @@ -95,7 +95,7 @@ public class ContainerUploadPageLayout extends WizardPage { // #################################### // Image Repository Input Panel - JPanel pnlImageRepo = new ContainerTabPanel(ContainerBuildContextMethod.IMAGE_REPO); + JPanel pnlImageRepo = new ContainerTabPanel(ContainerImageContext.IMAGE_REPOSITORY); pnlImageRepo.setVisible(true); tmpGrid = new GridManager(pnlImageRepo, 2, true, new Insets(0, 5, 0, 5)); QLabel lblImageRepo = new QLabel(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ImageRepo.label")); @@ -148,14 +148,14 @@ public class ContainerUploadPageLayout extends WizardPage { grid.finish(true); } - protected ContainerBuildContextMethod getBuildContextMethod() { + protected ContainerImageContext getCurrentContext() { return ((ContainerTabPanel) tpInput.getSelectedComponent()).containerImageContext; } static class ContainerTabPanel extends JPanel { - public final ContainerBuildContextMethod containerImageContext; + public final ContainerImageContext containerImageContext; - ContainerTabPanel(ContainerBuildContextMethod imageContext) { + ContainerTabPanel(ContainerImageContext imageContext) { this.containerImageContext = imageContext; } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java index 907c1c3b..878f07f8 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java @@ -218,14 +218,14 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { private boolean checkUserInput() { - switch (getBuildContextMethod()) { - case IMAGE_REPO: + switch (getCurrentContext()) { + case IMAGE_REPOSITORY: if (txtImageRepo.getText() == null || txtImageRepo.getText().isEmpty()) { setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoImageRepo")); return false; } break; - case FILE: + case DOCKERFILE: if (txtImageFile.getText() == null || txtImageFile.getText().isEmpty()) { setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoReceipt")); return false; @@ -241,7 +241,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { return false; } break; - case DOCKER_TAR: + case DOCKER_ARCHIVE: if (txtImageTar.getText() == null || txtImageTar.getText().isEmpty()) { setWarningMessage("No Image provided"); return false; @@ -262,15 +262,15 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { private VirtualizationConfigurationDocker createVirtualizationConfig() { - containerDefinition.getContainerMeta().setBuildContextMethod(getBuildContextMethod().ordinal()); + containerDefinition.getContainerMeta().setContainerImageContext(getCurrentContext().ordinal()); containerDefinition.getContainerMeta().setImageName(txtImageName.getText()); - switch (containerDefinition.getBuildContextMethod()) { - case FILE: + switch (containerDefinition.getContainerImageContext()) { + case DOCKERFILE: containerDefinition.setContainerRecipe(state.descriptionFile); state.diskFile = getDummyFile(); break; - case IMAGE_REPO: + case IMAGE_REPOSITORY: containerDefinition.getContainerMeta().setImageRepo(txtImageRepo.getText()); state.diskFile = getDummyFile(); state.descriptionFile = getDummyFile(); @@ -279,7 +279,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { state.diskFile = getDummyFile(); state.descriptionFile = getDummyFile(); break; - case DOCKER_TAR: + case DOCKER_ARCHIVE: state.diskFile = new File(txtImageTar.getText()); state.descriptionFile = getDummyFile(); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerWrapper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerWrapper.java index d7ce40a7..38ca2477 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerWrapper.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerWrapper.java @@ -19,10 +19,9 @@ public class ContainerWrapper { public static void unwrapContainer(File tmpDiskFile, String imageName, File destDir, byte[] virtualizerConfig) { ContainerDefinition conDef = ContainerDefinition.fromByteArray(virtualizerConfig); - String infoText; try { - switch (conDef.getBuildContextMethod()) { - case FILE: + switch (conDef.getContainerImageContext()) { + case DOCKERFILE: conDef.saveLocal(destDir); showImageMessageInfo(destDir.getPath(), "Dieses Image wird durch ein Dockerfile gebaut. Wechseln Sie in das Verzeichnis und bauen Sie das Image lokal (docker build)."); @@ -35,7 +34,7 @@ public class ContainerWrapper { showImageMessageInfo(conDef.getContainerMeta().getBuildContextUrl(), "Dieses Image wird durch ein öffentliches Git-Repository gebaut. Das Image kann mit dem angezeigten Link lokal gebaut werden (docker build), zudem können die Image-Quellen über diesen betrachtet werden."); break; - case IMAGE_REPO: + case IMAGE_REPOSITORY: Files.delete(tmpDiskFile.toPath()); Files.delete(destDir.toPath()); @@ -44,7 +43,7 @@ public class ContainerWrapper { "Dieses Image ist lediglich eine Referenz auf ein öffentliches Image. Das Image kann mittels des angezeigten Links gepullt werden." ); break; - case DOCKER_TAR: + case DOCKER_ARCHIVE: File destImage = new File(destDir.getAbsolutePath(), VmWrapper.generateFilename(imageName, "tar")); if (destImage.exists()) |