aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/jshipit/JshipIT.java
blob: becd91b804ee49aaa72623c8315c97c1a9d64871 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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(String[] args) {
        CommandStart commandStart = new CommandStart();
        CommandCreate commandCreate = new CommandCreate();
        CommandPull commandPull = new CommandPull();
        JCommander commands = JCommander.newBuilder()
                .addCommand("create", commandCreate)
                .addCommand("pull", commandPull)
                .addCommand("start", commandStart)
                .build();

        commands.parse(args);

        OCIDataStore dataStore = new OCIDataStore("./tmp");

        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, commandCreate.containerApiRepo, commandCreate.containerRepo, dataStore);
            containerManager.createContainer();
        } else if (commands.getParsedCommand().equals("pull")) {
            dataStore.createImage(commandPull.containerApiRepo, commandPull.containerRepo, commandPull.containerImage, commandPull.containerTag);
        } else if (commands.getParsedCommand().equals("start")) {
            ContainerManager containerManager = new ContainerManager(commandStart.containerName, dataStore);
            containerManager.runCommand(null);
        }



    }
}