aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/jshipit/JshipIT.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github/jshipit/JshipIT.java')
-rwxr-xr-xsrc/main/java/io/github/jshipit/JshipIT.java59
1 files changed, 24 insertions, 35 deletions
diff --git a/src/main/java/io/github/jshipit/JshipIT.java b/src/main/java/io/github/jshipit/JshipIT.java
index 5ccd96e..d51ddbe 100755
--- a/src/main/java/io/github/jshipit/JshipIT.java
+++ b/src/main/java/io/github/jshipit/JshipIT.java
@@ -1,51 +1,40 @@
package io.github.jshipit;
+import com.beust.jcommander.JCommander;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import com.beust.jcommander.Parameter;
public class JshipIT {
- public JshipIT() {
- /*
- DockerAPIHelper api = new DockerAPIHelper("registry.getcryst.al","crystal/misc", "docker", "latest");
- JsonNode manifest = null;
-
- System.out.println("API Token: " + api.getApiToken());
- try {
- manifest = api.fetchManifestJson();
- } catch (IOException ignored) {} // Proper error handling is bloat
-
- System.out.println("Manifest: " + manifest);
-
- Path path = Path.of("./tmp_"+api.getImage()+"_"+api.getTag());
- try {
- Files.createDirectory(path);
- } catch (IOException e) {
- System.out.println("Failed to create directory: " + path);
- e.printStackTrace();
- return;
- }
+ public JshipIT(String[] args) {
- assert manifest != null;
- JsonNode layers = manifest.get("layers");
- for (JsonNode layer : layers) {
- System.out.println("Layer: " + layer);
- try {
- api.fetchBlob(layer.get("digest").asText(), path.toString());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ CommandCreate commandCreate = new CommandCreate();
+ CommandPull commandPull = new CommandPull();
+ JCommander commands = JCommander.newBuilder()
+ .addCommand("create", commandCreate)
+ .addCommand("pull", commandPull)
+ .build();
- */
+ commands.parse(args);
OCIDataStore dataStore = new OCIDataStore("./tmp");
- //dataStore.createImage("registry.docker.io","library", "bash", "devel-alpine3.18");
- ContainerManager containerManager = new ContainerManager("testContainer", "bash", "devel-alpine3.18", "bash", "registry.docker.io", "library", dataStore);
- containerManager.createContainer();
- containerManager.startContainer();
+
+ if (commands.getParsedCommand() == null) {
+ commands.usage();
+ System.exit(1);
+ } else if (commands.getParsedCommand().equals("create")) {
+ ContainerManager containerManager = new ContainerManager(commandCreate.containerName, commandCreate.containerImage, commandCreate.containerTag, "bash", commandCreate.containerApiRepo, commandCreate.containerRepo, dataStore);
+ containerManager.createContainer();
+ containerManager.startContainer();
+ } else if (commands.getParsedCommand().equals("pull")) {
+ dataStore.createImage(commandPull.containerApiRepo, commandPull.containerRepo, commandPull.containerImage, commandPull.containerTag);
+ }
+
+
+
}
} \ No newline at end of file