aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/jshipit/JshipIT.java
blob: d51ddbe765b09413b6b27f3a31cd15b8570bccfa (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
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) {

        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");

        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);
        }



    }
}