diff --git a/pom.xml b/pom.xml
index 0e865947d..e3c627021 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
wtf.metio.maven.parents
maven-parents-java-stable
- 2022.10.28
+ 2022.11.25
@@ -94,6 +94,11 @@
com.fasterxml.jackson.dataformat
jackson-dataformat-yaml
+
+ wtf.metio.devcontainer
+ devcontainer.java
+ 2022.12.7
+
org.junit.jupiter
junit-jupiter-api
@@ -155,7 +160,7 @@
info.picocli
picocli-codegen
- 4.6.3
+ 4.7.0
@@ -195,7 +200,6 @@
org.graalvm.buildtools
native-maven-plugin
true
- 0.9.18
build-native
@@ -290,17 +294,17 @@
picocli.codegen.docgen.manpage.ManPageGenerator
--outdir=${project.build.directory}/generated-picocli-docs
- wtf.metio.ilo.shell.Shell
- wtf.metio.ilo.compose.Compose
- wtf.metio.ilo.devcontainer.Devcontainer
- wtf.metio.ilo.devfile.Devfile
+ wtf.metio.ilo.shell.ShellCommand
+ wtf.metio.ilo.compose.ComposeCommand
+ wtf.metio.ilo.devcontainer.DevcontainerCommand
+ wtf.metio.ilo.devfile.DevfileCommand
info.picocli
picocli-codegen
- 4.6.3
+ 4.7.0
jar
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index e93a34f9e..d3e1cc99f 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -3,10 +3,11 @@
requires info.picocli;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.dataformat.yaml;
+ requires wtf.metio.devcontainer;
opens wtf.metio.ilo to info.picocli;
opens wtf.metio.ilo.compose to info.picocli;
- opens wtf.metio.ilo.devcontainer to info.picocli, com.fasterxml.jackson.databind;
+ opens wtf.metio.ilo.devcontainer to info.picocli;
opens wtf.metio.ilo.devfile to info.picocli, com.fasterxml.jackson.databind;
opens wtf.metio.ilo.shell to info.picocli;
opens wtf.metio.ilo.version to info.picocli;
diff --git a/src/main/java/wtf/metio/ilo/Ilo.java b/src/main/java/wtf/metio/ilo/Ilo.java
index f86202ca2..e44bdcb6e 100644
--- a/src/main/java/wtf/metio/ilo/Ilo.java
+++ b/src/main/java/wtf/metio/ilo/Ilo.java
@@ -10,12 +10,12 @@
import picocli.AutoComplete;
import picocli.CommandLine;
import wtf.metio.ilo.cli.RunCommands;
-import wtf.metio.ilo.compose.Compose;
-import wtf.metio.ilo.devcontainer.Devcontainer;
-import wtf.metio.ilo.devfile.Devfile;
+import wtf.metio.ilo.compose.ComposeCommand;
+import wtf.metio.ilo.devcontainer.DevcontainerCommand;
+import wtf.metio.ilo.devfile.DevfileCommand;
import wtf.metio.ilo.errors.ExitCodes;
import wtf.metio.ilo.errors.PrintingExceptionHandler;
-import wtf.metio.ilo.shell.Shell;
+import wtf.metio.ilo.shell.ShellCommand;
import wtf.metio.ilo.version.VersionProvider;
import java.nio.file.Paths;
@@ -38,10 +38,10 @@
optionListHeading = "%nOptions:%n",
commandListHeading = "%nCommands:%n",
subcommands = {
- Shell.class,
- Compose.class,
- Devcontainer.class,
- Devfile.class,
+ ShellCommand.class,
+ ComposeCommand.class,
+ DevcontainerCommand.class,
+ DevfileCommand.class,
AutoComplete.GenerateCompletion.class
},
showDefaultValues = true
diff --git a/src/main/java/wtf/metio/ilo/compose/Compose.java b/src/main/java/wtf/metio/ilo/compose/ComposeCommand.java
similarity index 87%
rename from src/main/java/wtf/metio/ilo/compose/Compose.java
rename to src/main/java/wtf/metio/ilo/compose/ComposeCommand.java
index 8459ea16a..d50bc6cb4 100644
--- a/src/main/java/wtf/metio/ilo/compose/Compose.java
+++ b/src/main/java/wtf/metio/ilo/compose/ComposeCommand.java
@@ -25,7 +25,7 @@
descriptionHeading = "%n",
optionListHeading = "%n"
)
-public final class Compose implements Callable {
+public final class ComposeCommand implements Callable {
@CommandLine.Mixin
public ComposeOptions options;
@@ -33,12 +33,12 @@ public final class Compose implements Callable {
private final CliExecutor super ComposeRuntime, ComposeCLI, ComposeOptions> executor;
// default constructor for picocli
- public Compose() {
+ public ComposeCommand() {
this(new ComposeExecutor());
}
// constructor for testing
- Compose(final CliExecutor super ComposeRuntime, ComposeCLI, ComposeOptions> executor) {
+ ComposeCommand(final CliExecutor super ComposeRuntime, ComposeCLI, ComposeOptions> executor) {
this.executor = executor;
}
diff --git a/src/main/java/wtf/metio/ilo/compose/ComposeOptions.java b/src/main/java/wtf/metio/ilo/compose/ComposeOptions.java
index 9ac475f96..88b873948 100644
--- a/src/main/java/wtf/metio/ilo/compose/ComposeOptions.java
+++ b/src/main/java/wtf/metio/ilo/compose/ComposeOptions.java
@@ -22,9 +22,10 @@ public final class ComposeOptions implements Options {
public ComposeRuntime runtime;
@CommandLine.Option(
- names = {"--no-interactive"},
+ names = {"--interactive"},
description = "Allocate a pseudo TTY or not.",
defaultValue = "true",
+ fallbackValue = "true",
negatable = true
)
public boolean interactive;
diff --git a/src/main/java/wtf/metio/ilo/compose/DockerCompose2.java b/src/main/java/wtf/metio/ilo/compose/DockerCompose2.java
index 8ed415b01..8ae969329 100644
--- a/src/main/java/wtf/metio/ilo/compose/DockerCompose2.java
+++ b/src/main/java/wtf/metio/ilo/compose/DockerCompose2.java
@@ -8,7 +8,7 @@
package wtf.metio.ilo.compose;
/**
- * Support for 'docker compose' aka 'Compose V2'
+ * Support for 'docker compose' aka 'ComposeCommand V2'
*
* @see official documentation
*/
diff --git a/src/main/java/wtf/metio/ilo/devcontainer/Devcontainer.java b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerCommand.java
similarity index 63%
rename from src/main/java/wtf/metio/ilo/devcontainer/Devcontainer.java
rename to src/main/java/wtf/metio/ilo/devcontainer/DevcontainerCommand.java
index 5e3110bc1..38aa9722c 100644
--- a/src/main/java/wtf/metio/ilo/devcontainer/Devcontainer.java
+++ b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerCommand.java
@@ -8,16 +8,19 @@
package wtf.metio.ilo.devcontainer;
import picocli.CommandLine;
-import wtf.metio.ilo.compose.Compose;
-import wtf.metio.ilo.shell.Shell;
+import wtf.metio.devcontainer.Devcontainer;
+import wtf.metio.ilo.compose.ComposeCommand;
+import wtf.metio.ilo.errors.DevcontainerJsonMissingException;
+import wtf.metio.ilo.shell.ShellCommand;
+import wtf.metio.ilo.utils.Streams;
import wtf.metio.ilo.utils.Strings;
import wtf.metio.ilo.version.VersionProvider;
+import java.io.IOException;
import java.nio.file.Paths;
+import java.util.Objects;
import java.util.concurrent.Callable;
-import static wtf.metio.ilo.devcontainer.DevcontainerJsonParser.findJson;
-import static wtf.metio.ilo.devcontainer.DevcontainerJsonParser.parseJson;
import static wtf.metio.ilo.devcontainer.DevcontainerOptionsMapper.composeOptions;
import static wtf.metio.ilo.devcontainer.DevcontainerOptionsMapper.shellOptions;
@@ -32,23 +35,24 @@
descriptionHeading = "%n",
optionListHeading = "%n"
)
-public final class Devcontainer implements Callable {
+public final class DevcontainerCommand implements Callable {
@CommandLine.Mixin
public DevcontainerOptions options;
@Override
- public Integer call() {
+ public Integer call() throws IOException {
final var currentDir = Paths.get(System.getProperty("user.dir"));
- final var json = findJson(currentDir, options.locations);
- final var devcontainer = parseJson(json);
+ final var json = Streams.findFirst(currentDir, options.locations)
+ .orElseThrow(DevcontainerJsonMissingException::new);
+ final var devcontainer = Devcontainer.parse(json);
- if (null != devcontainer.dockerComposeFile && !devcontainer.dockerComposeFile.isEmpty()) {
- final var command = new Compose();
+ if (Objects.nonNull(devcontainer.dockerComposeFile()) && !devcontainer.dockerComposeFile().isEmpty()) {
+ final var command = new ComposeCommand();
command.options = composeOptions(options, devcontainer, json);
return command.call();
- } else if (Strings.isNotBlank(devcontainer.image)) {
- final var command = new Shell();
+ } else if (Strings.isNotBlank(devcontainer.image())) {
+ final var command = new ShellCommand();
command.options = shellOptions(options, devcontainer);
return command.call();
}
diff --git a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJson.java b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJson.java
deleted file mode 100644
index 82a124f3a..000000000
--- a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJson.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of ilo. It is subject to the license terms in the LICENSE file found in the top-level
- * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of ilo,
- * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-package wtf.metio.ilo.devcontainer;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @see devcontainer reference
- */
-final class DevcontainerJson {
-
- //region general
- public String name;
- public String remoteUser;
- public Map remoteEnv;
- public String workspaceFolder;
- //endregion
-
- //region shell
- public String image;
- public String dockerFile;
- public String context;
- public List forwardPorts;
- public String containerUser;
- public List runArgs;
- public Map containerEnv;
- public boolean overrideCommand;
- public Build build;
- //endregion
-
- //region compose
- public List dockerComposeFile;
- public String service;
- public List runServices;
- //endregion
-
- static final class Build {
- public String dockerFile;
- public String context;
- public Map args;
- public String target;
- }
-
-}
diff --git a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParser.java b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParser.java
deleted file mode 100644
index 051211f66..000000000
--- a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParser.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of ilo. It is subject to the license terms in the LICENSE file found in the top-level
- * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of ilo,
- * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-package wtf.metio.ilo.devcontainer;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import wtf.metio.ilo.errors.DevcontainerJsonMissingException;
-import wtf.metio.ilo.errors.JsonParsingException;
-import wtf.metio.ilo.errors.RuntimeIOException;
-import wtf.metio.ilo.utils.Streams;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-
-final class DevcontainerJsonParser {
-
- static Path findJson(final Path baseDirectory, final List locations) {
- return Streams.findFirst(baseDirectory, locations).orElseThrow(DevcontainerJsonMissingException::new);
- }
-
- static DevcontainerJson parseJson(final Path devcontainer) {
- try {
- final var json = Files.readString(devcontainer);
- final var mapper = new ObjectMapper();
- mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- return mapper.readValue(json, DevcontainerJson.class);
- } catch (final JsonProcessingException exception) {
- throw new JsonParsingException(exception);
- } catch (final IOException exception) {
- throw new RuntimeIOException(exception);
- }
- }
-
- private DevcontainerJsonParser() {
- // utility class
- }
-
-}
diff --git a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptions.java b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptions.java
index 29e2baa9c..eb7aeaf9e 100644
--- a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptions.java
+++ b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptions.java
@@ -48,6 +48,7 @@ public final class DevcontainerOptions implements Options {
names = {"--mount-project-dir"},
description = "Mount the project directory into the running container.",
defaultValue = "true",
+ fallbackValue = "true",
negatable = true
)
public boolean mountProjectDir;
diff --git a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapper.java b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapper.java
index d25433d9c..eb32e5137 100644
--- a/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapper.java
+++ b/src/main/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapper.java
@@ -7,8 +7,10 @@
package wtf.metio.ilo.devcontainer;
+import wtf.metio.devcontainer.Build;
import wtf.metio.ilo.compose.ComposeOptions;
import wtf.metio.ilo.shell.ShellOptions;
+import wtf.metio.devcontainer.Devcontainer;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -18,39 +20,37 @@
final class DevcontainerOptionsMapper {
- static ShellOptions shellOptions(final DevcontainerOptions options, final DevcontainerJson devcontainer) {
+ static ShellOptions shellOptions(final DevcontainerOptions options, final Devcontainer devcontainer) {
final var opts = new ShellOptions();
opts.debug = options.debug;
opts.pull = options.pull;
opts.removeImage = options.removeImage;
opts.runtime = options.shellRuntime;
opts.mountProjectDir = options.mountProjectDir;
- opts.image = devcontainer.image;
- opts.context = Optional.ofNullable(devcontainer.build)
- .map(build -> build.context)
- .or(() -> Optional.ofNullable(devcontainer.context))
+ opts.image = devcontainer.image();
+ opts.context = Optional.ofNullable(devcontainer.build())
+ .map(Build::context)
.orElse(".");
- opts.containerfile = Optional.ofNullable(devcontainer.build)
- .map(build -> build.dockerFile)
- .or(() -> Optional.ofNullable(devcontainer.dockerFile))
+ opts.containerfile = Optional.ofNullable(devcontainer.build())
+ .map(Build::dockerfile)
.orElse("");
- opts.ports = Stream.ofNullable(devcontainer.forwardPorts)
+ opts.ports = Stream.ofNullable(devcontainer.forwardPorts())
.flatMap(Collection::stream)
.map(port -> port + ":" + port)
.toList();
return opts;
}
- static ComposeOptions composeOptions(final DevcontainerOptions options, final DevcontainerJson devcontainer, final Path devcontainerJson) {
+ static ComposeOptions composeOptions(final DevcontainerOptions options, final Devcontainer devcontainer, final Path devcontainerJson) {
final var opts = new ComposeOptions();
- opts.file = Stream.ofNullable(devcontainer.dockerComposeFile)
+ opts.file = Stream.ofNullable(devcontainer.dockerComposeFile())
.flatMap(Collection::stream)
.map(Paths::get)
.map(devcontainerJson::relativize)
.map(Path::toAbsolutePath)
.map(Path::toString)
.toList();
- opts.service = devcontainer.service;
+ opts.service = devcontainer.service();
opts.debug = options.debug;
opts.pull = options.pull;
opts.runtime = options.composeRuntime;
diff --git a/src/main/java/wtf/metio/ilo/devfile/Devfile.java b/src/main/java/wtf/metio/ilo/devfile/DevfileCommand.java
similarity index 91%
rename from src/main/java/wtf/metio/ilo/devfile/Devfile.java
rename to src/main/java/wtf/metio/ilo/devfile/DevfileCommand.java
index 83b2da222..ef8054e85 100644
--- a/src/main/java/wtf/metio/ilo/devfile/Devfile.java
+++ b/src/main/java/wtf/metio/ilo/devfile/DevfileCommand.java
@@ -8,7 +8,7 @@
package wtf.metio.ilo.devfile;
import picocli.CommandLine;
-import wtf.metio.ilo.shell.Shell;
+import wtf.metio.ilo.shell.ShellCommand;
import wtf.metio.ilo.shell.ShellOptions;
import wtf.metio.ilo.utils.Streams;
import wtf.metio.ilo.utils.Strings;
@@ -34,7 +34,7 @@
descriptionHeading = "%n",
optionListHeading = "%n"
)
-public final class Devfile implements Callable {
+public final class DevfileCommand implements Callable {
@CommandLine.Mixin
public DevfileOptions options;
@@ -46,7 +46,7 @@ public Integer call() {
final var devfile = parseDevfile(yaml);
if (hasSupportedDevfileConfiguration(devfile, options.component)) {
- final var command = new Shell();
+ final var command = new ShellCommand();
command.options = mapOptions(options, devfile);
return command.call();
}
@@ -74,16 +74,16 @@ private static boolean usesLocalDockerfile(final DevfileYaml.Component component
static ShellOptions mapOptions(final DevfileOptions options, final DevfileYaml devfile) {
final var opts = Stream.ofNullable(devfile.components)
.flatMap(Collection::stream)
- .filter(Devfile::usesPredefinedImage)
+ .filter(DevfileCommand::usesPredefinedImage)
.map(component -> component.container)
.findFirst()
- .map(Devfile::optionsForPredefinedImage)
+ .map(DevfileCommand::optionsForPredefinedImage)
.or(() -> Stream.ofNullable(devfile.components)
.flatMap(Collection::stream)
- .filter(Devfile::usesLocalDockerfile)
+ .filter(DevfileCommand::usesLocalDockerfile)
.map(component -> component.image)
.findFirst()
- .map(Devfile::optionsForLocalDockerfile))
+ .map(DevfileCommand::optionsForLocalDockerfile))
.orElseThrow();
opts.debug = options.debug;
diff --git a/src/main/java/wtf/metio/ilo/devfile/DevfileYaml.java b/src/main/java/wtf/metio/ilo/devfile/DevfileYaml.java
index 5f4ad75e9..35bc2fc35 100644
--- a/src/main/java/wtf/metio/ilo/devfile/DevfileYaml.java
+++ b/src/main/java/wtf/metio/ilo/devfile/DevfileYaml.java
@@ -197,7 +197,7 @@ static final class Dockerfile {
public String uri;
/**
- * Dockerfile's Devfile Registry source.
+ * Dockerfile's DevfileCommand Registry source.
*/
public DevfileRegistry devfileRegistry;
@@ -217,7 +217,7 @@ static final class DevfileRegistry {
public String id;
/**
- * Devfile Registry URL to pull the Dockerfile from when using the Devfile Registry as Dockerfile src.
+ * DevfileCommand Registry URL to pull the Dockerfile from when using the DevfileCommand Registry as Dockerfile src.
*/
public String registryUrl;
@@ -273,7 +273,7 @@ static final class Volume {
}
/**
- * Devfile schema version.
+ * DevfileCommand schema version.
*/
public String schemaVersion;
diff --git a/src/main/java/wtf/metio/ilo/os/PosixShell.java b/src/main/java/wtf/metio/ilo/os/PosixShell.java
index 19acfdf09..ea77f3d41 100644
--- a/src/main/java/wtf/metio/ilo/os/PosixShell.java
+++ b/src/main/java/wtf/metio/ilo/os/PosixShell.java
@@ -15,7 +15,7 @@
/**
* Support for POSIX compatible shells.
*
- * @see Shell Command Language
+ * @see ShellCommand Command Language
*/
final class PosixShell extends ParameterExpansion {
diff --git a/src/main/java/wtf/metio/ilo/shell/Shell.java b/src/main/java/wtf/metio/ilo/shell/ShellCommand.java
similarity index 67%
rename from src/main/java/wtf/metio/ilo/shell/Shell.java
rename to src/main/java/wtf/metio/ilo/shell/ShellCommand.java
index cf7d03f4d..aef8e8dc3 100644
--- a/src/main/java/wtf/metio/ilo/shell/Shell.java
+++ b/src/main/java/wtf/metio/ilo/shell/ShellCommand.java
@@ -15,17 +15,17 @@
import java.util.concurrent.Callable;
@CommandLine.Command(
- name = "shell",
- description = "Opens an (interactive) shell for your build environment",
- versionProvider = VersionProvider.class,
- mixinStandardHelpOptions = true,
- showAtFileInUsageHelp = true,
- usageHelpAutoWidth = true,
- showDefaultValues = true,
- descriptionHeading = "%n",
- parameterListHeading = "%n"
+ name = "shell",
+ description = "Opens an (interactive) shell for your build environment",
+ versionProvider = VersionProvider.class,
+ mixinStandardHelpOptions = true,
+ showAtFileInUsageHelp = true,
+ usageHelpAutoWidth = true,
+ showDefaultValues = true,
+ descriptionHeading = "%n",
+ parameterListHeading = "%n"
)
-public final class Shell implements Callable {
+public final class ShellCommand implements Callable {
@CommandLine.Mixin
public ShellOptions options;
@@ -33,12 +33,12 @@ public final class Shell implements Callable {
private final CliExecutor super ShellRuntime, ShellCLI, ShellOptions> executor;
// default constructor for picocli
- public Shell() {
+ public ShellCommand() {
this(new ShellExecutor());
}
// constructor for testing
- Shell(final CliExecutor super ShellRuntime, ShellCLI, ShellOptions> executor) {
+ ShellCommand(final CliExecutor super ShellRuntime, ShellCLI, ShellOptions> executor) {
this.executor = executor;
}
diff --git a/src/main/java/wtf/metio/ilo/shell/ShellOptions.java b/src/main/java/wtf/metio/ilo/shell/ShellOptions.java
index 9922eff8f..a5397d25c 100644
--- a/src/main/java/wtf/metio/ilo/shell/ShellOptions.java
+++ b/src/main/java/wtf/metio/ilo/shell/ShellOptions.java
@@ -15,37 +15,39 @@
public final class ShellOptions implements Options {
@CommandLine.Option(
- names = {"--runtime"},
- description = "Specify the runtime to use. If none is specified, use auto-selection.",
- converter = ShellRuntimeConverter.class
+ names = {"--runtime"},
+ description = "Specify the runtime to use. If none is specified, use auto-selection.",
+ converter = ShellRuntimeConverter.class
)
public ShellRuntime runtime;
@CommandLine.Option(
- names = {"--debug"},
- description = "Show additional debug information."
+ names = {"--debug"},
+ description = "Show additional debug information."
)
public boolean debug;
@CommandLine.Option(
- names = {"--pull"},
- description = "Pull image before opening shell."
+ names = {"--pull"},
+ description = "Pull image before opening shell."
)
public boolean pull;
@CommandLine.Option(
- names = {"--no-interactive"},
- description = "Open interactive shell or just run a single command.",
- defaultValue = "true",
- negatable = true
+ names = {"--interactive"},
+ description = "Open interactive shell or just run a single command.",
+ defaultValue = "true",
+ fallbackValue = "true",
+ negatable = true
)
public boolean interactive;
@CommandLine.Option(
- names = {"--no-mount-project-dir"},
- description = "Mount the project directory into the running container. Container path will be the same as --working-dir.",
- defaultValue = "true",
- negatable = true
+ names = {"--mount-project-dir"},
+ description = "Mount the project directory into the running container. Container path will be the same as --working-dir.",
+ defaultValue = "true",
+ fallbackValue = "true",
+ negatable = true
)
public boolean mountProjectDir;
@@ -56,101 +58,101 @@ public final class ShellOptions implements Options {
public String workingDir;
@CommandLine.Option(
- names = {"--containerfile", "--dockerfile"},
- description = "The Containerfile to use."
+ names = {"--containerfile", "--dockerfile"},
+ description = "The Containerfile to use."
)
public String containerfile;
@CommandLine.Option(
- names = {"--context"},
- description = "The context to use when building an image.",
- defaultValue = "."
+ names = {"--context"},
+ description = "The context to use when building an image.",
+ defaultValue = "."
)
public String context;
@CommandLine.Option(
- names = {"--hostname"},
- description = "The hostname of the running container."
+ names = {"--hostname"},
+ description = "The hostname of the running container."
)
public String hostname;
@CommandLine.Option(
- names = {"--remove-image"},
- description = "Remove image after closing the shell."
+ names = {"--remove-image"},
+ description = "Remove image after closing the shell."
)
public boolean removeImage;
@CommandLine.Option(
- names = {"--run-as"},
- description = "Run the container as the specified user:group."
+ names = {"--run-as"},
+ description = "Run the container as the specified user:group."
)
public String runAs;
@CommandLine.Option(
- names = {"--runtime-option"},
- description = "Options for the selected runtime itself."
+ names = {"--runtime-option"},
+ description = "Options for the selected runtime itself."
)
public List runtimeOptions;
@CommandLine.Option(
- names = {"--runtime-pull-option"},
- description = "Options for the pull command of the selected runtime."
+ names = {"--runtime-pull-option"},
+ description = "Options for the pull command of the selected runtime."
)
public List runtimePullOptions;
@CommandLine.Option(
- names = {"--runtime-build-option"},
- description = "Options for the build command of the selected runtime."
+ names = {"--runtime-build-option"},
+ description = "Options for the build command of the selected runtime."
)
public List runtimeBuildOptions;
@CommandLine.Option(
- names = {"--runtime-run-option"},
- description = "Options for the run command of the selected runtime."
+ names = {"--runtime-run-option"},
+ description = "Options for the run command of the selected runtime."
)
public List runtimeRunOptions;
@CommandLine.Option(
- names = {"--runtime-cleanup-option"},
- description = "Options for the cleanup command of the selected runtime."
+ names = {"--runtime-cleanup-option"},
+ description = "Options for the cleanup command of the selected runtime."
)
public List runtimeCleanupOptions;
@CommandLine.Option(
- names = {"--volume"},
- description = "Mount a volume into the container."
+ names = {"--volume"},
+ description = "Mount a volume into the container."
)
public List volumes;
@CommandLine.Option(
- names = {"--missing-volumes"},
- description = "Specifies how missing local volume directories should be handles. Valid values: ${COMPLETION-CANDIDATES}",
- defaultValue = "CREATE"
+ names = {"--missing-volumes"},
+ description = "Specifies how missing local volume directories should be handles. Valid values: ${COMPLETION-CANDIDATES}",
+ defaultValue = "CREATE"
)
public ShellVolumeBehavior missingVolumes;
@CommandLine.Option(
- names = {"--env"},
- description = "Specify a environment variable for the container."
+ names = {"--env"},
+ description = "Specify a environment variable for the container."
)
public List variables;
@CommandLine.Option(
- names = {"--publish"},
- description = "Publish container ports to the host system."
+ names = {"--publish"},
+ description = "Publish container ports to the host system."
)
public List ports;
@CommandLine.Parameters(
- index = "0",
- description = "The OCI image to use. In case --containerfile or --dockerfile is given as well, this defines the name of the resulting image.",
- defaultValue = "fedora:latest"
+ index = "0",
+ description = "The OCI image to use. In case --containerfile or --dockerfile is given as well, this defines the name of the resulting image.",
+ defaultValue = "fedora:latest"
)
public String image;
@CommandLine.Parameters(
- index = "1..*",
- description = "Command and its option(s) to run inside the container. Overwrites the command specified in the image."
+ index = "1..*",
+ description = "Command and its option(s) to run inside the container. Overwrites the command specified in the image."
)
public List commands;
diff --git a/src/test/java/wtf/metio/ilo/PicocliBooleanTest.java b/src/test/java/wtf/metio/ilo/PicocliBooleanTest.java
index 1de7df28f..ac5b6900b 100644
--- a/src/test/java/wtf/metio/ilo/PicocliBooleanTest.java
+++ b/src/test/java/wtf/metio/ilo/PicocliBooleanTest.java
@@ -45,6 +45,14 @@ static class TestCommand implements Runnable {
)
public boolean human;
+ @CommandLine.Option(
+ names = {"--wanted"},
+ defaultValue = "true",
+ fallbackValue = "true",
+ negatable = true
+ )
+ public boolean wanted;
+
@Override
public void run() {}
@@ -58,79 +66,86 @@ public void optionNotSpecified() {
() -> assertTrue(command.interactive, "interactive"),
() -> assertFalse(command.autonomous, "autonomous"),
() -> assertTrue(command.daemon, "daemon"),
- () -> assertFalse(command.human, "human")
+ () -> assertFalse(command.human, "human"),
+ () -> assertTrue(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithoutValue() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--interactive", "--autonomous", "--daemon", "--human");
+ new CommandLine(command).parseArgs("--interactive", "--autonomous", "--daemon", "--human", "--wanted");
assertAll(
() -> assertTrue(command.interactive, "interactive"),
() -> assertFalse(command.autonomous, "autonomous"),
() -> assertFalse(command.daemon, "daemon"),
- () -> assertTrue(command.human, "human")
+ () -> assertTrue(command.human, "human"),
+ () -> assertTrue(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithBooleanTrue() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--interactive=true", "--autonomous=true", "--daemon=true", "--human=true");
+ new CommandLine(command).parseArgs("--interactive=true", "--autonomous=true", "--daemon=true", "--human=true", "--wanted=true");
assertAll(
- () -> assertTrue(command.interactive, "interactive"),
- () -> assertTrue(command.autonomous, "autonomous"),
+ () -> assertFalse(command.interactive, "interactive"),
+ () -> assertFalse(command.autonomous, "autonomous"),
() -> assertTrue(command.daemon, "daemon"),
- () -> assertTrue(command.human, "human")
+ () -> assertTrue(command.human, "human"),
+ () -> assertTrue(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithBooleanFalse() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--interactive=false", "--autonomous=false", "--daemon=false", "--human=false");
+ new CommandLine(command).parseArgs("--interactive=false", "--autonomous=false", "--daemon=false", "--human=false", "--wanted=false");
assertAll(
- () -> assertFalse(command.interactive, "interactive"),
- () -> assertFalse(command.autonomous, "autonomous"),
+ () -> assertTrue(command.interactive, "interactive"),
+ () -> assertTrue(command.autonomous, "autonomous"),
() -> assertFalse(command.daemon, "daemon"),
- () -> assertFalse(command.human, "human")
+ () -> assertFalse(command.human, "human"),
+ () -> assertFalse(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithNegatedForm() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--no-interactive", "--no-autonomous", "--no-daemon", "--no-human");
+ new CommandLine(command).parseArgs("--no-interactive", "--no-autonomous", "--no-daemon", "--no-human", "--no-wanted");
assertAll(
() -> assertFalse(command.interactive, "interactive"),
() -> assertTrue(command.autonomous, "autonomous"),
() -> assertTrue(command.daemon, "daemon"),
- () -> assertFalse(command.human, "human")
+ () -> assertFalse(command.human, "human"),
+ () -> assertFalse(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithNegatedFormUsingBooleanTrue() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--no-interactive=true", "--no-autonomous=true", "--no-daemon=true", "--no-human=true");
+ new CommandLine(command).parseArgs("--no-interactive=true", "--no-autonomous=true", "--no-daemon=true", "--no-human=true", "--no-wanted=true");
assertAll(
() -> assertTrue(command.interactive, "interactive"),
() -> assertTrue(command.autonomous, "autonomous"),
- () -> assertTrue(command.daemon, "daemon"),
- () -> assertTrue(command.human, "human")
+ () -> assertFalse(command.daemon, "daemon"),
+ () -> assertFalse(command.human, "human"),
+ () -> assertFalse(command.wanted, "wanted")
);
}
@Test
public void optionSpecifiedWithNegatedFormUsingBooleanFalse() {
final var command = new TestCommand();
- new CommandLine(command).parseArgs("--no-interactive=false", "--no-autonomous=false", "--no-daemon=false", "--no-human=false");
+ new CommandLine(command).parseArgs("--no-interactive=false", "--no-autonomous=false", "--no-daemon=false", "--no-human=false", "--no-wanted=false");
assertAll(
() -> assertFalse(command.interactive, "interactive"),
() -> assertFalse(command.autonomous, "autonomous"),
- () -> assertFalse(command.daemon, "daemon"),
- () -> assertFalse(command.human, "human")
+ () -> assertTrue(command.daemon, "daemon"),
+ () -> assertTrue(command.human, "human"),
+ () -> assertTrue(command.wanted, "wanted")
);
}
diff --git a/src/test/java/wtf/metio/ilo/acceptance/CLI_TCK.java b/src/test/java/wtf/metio/ilo/acceptance/CLI_TCK.java
index 7087a313c..3a8855a5e 100644
--- a/src/test/java/wtf/metio/ilo/acceptance/CLI_TCK.java
+++ b/src/test/java/wtf/metio/ilo/acceptance/CLI_TCK.java
@@ -10,10 +10,10 @@
import org.junit.jupiter.api.BeforeEach;
import picocli.CommandLine;
import wtf.metio.ilo.Ilo;
-import wtf.metio.ilo.compose.Compose;
-import wtf.metio.ilo.devcontainer.Devcontainer;
-import wtf.metio.ilo.devfile.Devfile;
-import wtf.metio.ilo.shell.Shell;
+import wtf.metio.ilo.compose.ComposeCommand;
+import wtf.metio.ilo.devcontainer.DevcontainerCommand;
+import wtf.metio.ilo.devfile.DevfileCommand;
+import wtf.metio.ilo.shell.ShellCommand;
import wtf.metio.ilo.test.TestMethodSources;
import java.io.PrintWriter;
@@ -31,28 +31,28 @@ final void initializeCLI() {
cmd.setOut(new PrintWriter(output));
}
- protected final Shell parseShellCommand(final String... args) {
+ protected final ShellCommand parseShellCommand(final String... args) {
final var parseResult = cmd.parseArgs(args);
final var subcommand = parseResult.subcommand();
- return (Shell) subcommand.commandSpec().userObject();
+ return (ShellCommand) subcommand.commandSpec().userObject();
}
- protected final Compose parseComposeCommand(final String... args) {
+ protected final ComposeCommand parseComposeCommand(final String... args) {
final var parseResult = cmd.parseArgs(args);
final var subcommand = parseResult.subcommand();
- return (Compose) subcommand.commandSpec().userObject();
+ return (ComposeCommand) subcommand.commandSpec().userObject();
}
- protected final Devcontainer parseDevcontainerCommand(final String... args) {
+ protected final DevcontainerCommand parseDevcontainerCommand(final String... args) {
final var parseResult = cmd.parseArgs(args);
final var subcommand = parseResult.subcommand();
- return (Devcontainer) subcommand.commandSpec().userObject();
+ return (DevcontainerCommand) subcommand.commandSpec().userObject();
}
- protected final Devfile parseDevfileCommand(final String... args) {
+ protected final DevfileCommand parseDevfileCommand(final String... args) {
final var parseResult = cmd.parseArgs(args);
final var subcommand = parseResult.subcommand();
- return (Devfile) subcommand.commandSpec().userObject();
+ return (DevfileCommand) subcommand.commandSpec().userObject();
}
}
diff --git a/src/test/java/wtf/metio/ilo/compose/ComposeTest.java b/src/test/java/wtf/metio/ilo/compose/ComposeCommandTest.java
similarity index 98%
rename from src/test/java/wtf/metio/ilo/compose/ComposeTest.java
rename to src/test/java/wtf/metio/ilo/compose/ComposeCommandTest.java
index 01334c5d7..75cfee55c 100644
--- a/src/test/java/wtf/metio/ilo/compose/ComposeTest.java
+++ b/src/test/java/wtf/metio/ilo/compose/ComposeCommandTest.java
@@ -20,12 +20,12 @@
import static org.junit.jupiter.api.Assertions.*;
-@DisplayName("Compose")
-class ComposeTest extends TestMethodSources {
+@DisplayName("ComposeCommand")
+class ComposeCommandTest extends TestMethodSources {
private static final String DOCKER_COMPOSE_YML = "docker-compose.yml";
- private Compose compose;
+ private ComposeCommand compose;
private TestComposeExecutor executor;
private ComposeOptions options;
@@ -34,7 +34,7 @@ void setUp() {
executor = new TestComposeExecutor();
options = new ComposeOptions();
options.file = List.of(DOCKER_COMPOSE_YML);
- compose = new Compose(executor);
+ compose = new ComposeCommand(executor);
compose.options = options;
}
diff --git a/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParserTest.java b/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParserTest.java
deleted file mode 100644
index 3ceaef79c..000000000
--- a/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerJsonParserTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * This file is part of ilo. It is subject to the license terms in the LICENSE file found in the top-level
- * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of ilo,
- * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-package wtf.metio.ilo.devcontainer;
-
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import wtf.metio.ilo.errors.DevcontainerJsonMissingException;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.*;
-import static wtf.metio.ilo.devcontainer.DevcontainerJsonParser.findJson;
-import static wtf.metio.ilo.test.TestResources.testResources;
-
-@DisplayName("DevcontainerJsonParser")
-class DevcontainerJsonParserTest {
-
- private static final List DEFAULT_LOCATIONS = List.of(".devcontainer/devcontainer.json", ".devcontainer.json");
-
- @Test
- @DisplayName("finds devcontainer.json in project root")
- void shouldFindRootJson() {
- assertTrue(Files.exists(findJsonIn("root")));
- }
-
- @Test
- @DisplayName("finds devcontainer.json in .devcontainer folder")
- void shouldFindNestedJson() {
- assertTrue(Files.exists(findJsonIn("nested")));
- }
-
- @Test
- @DisplayName("throws exception for missing devcontainer.json")
- void shouldNotFindMissingJson() {
- assertThrows(DevcontainerJsonMissingException.class, () -> findJsonIn("not-found"));
- }
-
- @Test
- @DisplayName("ignores directories called .devcontainer.json")
- void shouldIgnoreDirectories() {
- assertThrows(DevcontainerJsonMissingException.class, () -> findJsonIn("directory"));
- }
-
- @Test
- @DisplayName("can parse devcontainer.json for shell")
- void shouldParseShellJson() {
- final var devcontainer = DevcontainerJsonParser.parseJson(findJsonIn("shell"));
- assertAll("shell",
- () -> assertEquals("example:123", devcontainer.image, "image"),
- () -> assertEquals("my.dockerfile", devcontainer.dockerFile, "dockerFile"),
- () -> assertEquals("testUser", devcontainer.remoteUser, "remoteUser"),
- () -> assertEquals("root", devcontainer.containerUser, "containerUser"),
- () -> assertEquals("/home/testUser/project", devcontainer.workspaceFolder, "workspaceFolder"),
- () -> assertTrue(devcontainer.overrideCommand, "overrideCommand"),
- () -> assertIterableEquals(List.of(12345, 9876), devcontainer.forwardPorts, "forwardPorts"),
- () -> assertIterableEquals(List.of("--pull"), devcontainer.runArgs, "runArgs"),
- () -> assertEquals("value", devcontainer.remoteEnv.get("key"), "remoteEnv"),
- () -> assertEquals("yes", devcontainer.containerEnv.get("CI"), "containerEnv"),
- () -> assertEquals("other.dockerfile", devcontainer.build.dockerFile, "build.dockerFile"),
- () -> assertEquals(".", devcontainer.build.context, "build.context"),
- () -> assertEquals("dev", devcontainer.build.target, "build.target"),
- () -> assertEquals("value", devcontainer.build.args.get("some"), "build.args"));
- }
-
- @Test
- @DisplayName("can parse small devcontainer.json for shell")
- void shouldParseShellSmallJson() {
- final var devcontainer = DevcontainerJsonParser.parseJson(findJsonIn("shell-small"));
- assertAll("shell small",
- () -> assertEquals("example:123", devcontainer.image, "image"),
- () -> assertNull(devcontainer.dockerFile, "dockerFile"),
- () -> assertNull(devcontainer.remoteUser, "remoteUser"),
- () -> assertNull(devcontainer.containerUser, "containerUser"),
- () -> assertNull(devcontainer.workspaceFolder, "workspaceFolder"),
- () -> assertFalse(devcontainer.overrideCommand, "overrideCommand"),
- () -> assertNull(devcontainer.forwardPorts, "forwardPorts"),
- () -> assertNull(devcontainer.runArgs, "runArgs"),
- () -> assertNull(devcontainer.remoteEnv, "remoteEnv"),
- () -> assertNull(devcontainer.containerEnv, "containerEnv"),
- () -> assertNull(devcontainer.build, "build"));
- }
-
- @Test
- @DisplayName("can parse devcontainer.json for compose")
- void shouldParseComposeJson() {
- final var devcontainer = DevcontainerJsonParser.parseJson(findJsonIn("compose"));
- assertAll("compose",
- () -> assertIterableEquals(List.of("some-file.yml"), devcontainer.dockerComposeFile, "dockerComposeFile"),
- () -> assertEquals("dev", devcontainer.service, "service"),
- () -> assertEquals("my-name", devcontainer.name, "name"),
- () -> assertIterableEquals(List.of("first", "second"), devcontainer.runServices, "runServices"));
- }
-
- private Path findJsonIn(final String testDirectory) {
- return findJson(testResources(DevcontainerJsonParser.class).resolve(testDirectory), DEFAULT_LOCATIONS);
- }
-
-}
diff --git a/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapperTest.java b/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapperTest.java
index dd354d88f..5559df7ca 100644
--- a/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapperTest.java
+++ b/src/test/java/wtf/metio/ilo/devcontainer/DevcontainerOptionsMapperTest.java
@@ -10,6 +10,8 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
+import wtf.metio.devcontainer.BuildBuilder;
+import wtf.metio.devcontainer.DevcontainerBuilder;
import java.nio.file.Paths;
import java.util.List;
@@ -28,7 +30,7 @@ class ShellOptionsMapper {
@Test
@DisplayName("returns non-null values")
void shouldReturnNonNullValues() {
- assertNotNull(shellOptions(new DevcontainerOptions(), new DevcontainerJson()));
+ assertNotNull(shellOptions(new DevcontainerOptions(), DevcontainerBuilder.builder().create()));
}
@Test
@@ -36,14 +38,13 @@ void shouldReturnNonNullValues() {
void shouldMapImage() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.image = "example:123";
+ final var json = DevcontainerBuilder.builder().image("example:123").create();
// when
final var shellOptions = shellOptions(options, json);
// then
- assertEquals(json.image, shellOptions.image);
+ assertEquals(json.image(), shellOptions.image);
}
@Test
@@ -51,14 +52,13 @@ void shouldMapImage() {
void shouldMapDockerfile() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.dockerFile = "some.dockerfile";
+ final var json = DevcontainerBuilder.builder().build(BuildBuilder.builder().dockerfile("some.dockerfile").create()).create();
// when
final var shellOptions = shellOptions(options, json);
// then
- assertEquals(json.dockerFile, shellOptions.containerfile);
+ assertEquals(json.build().dockerfile(), shellOptions.containerfile);
}
@Test
@@ -66,61 +66,13 @@ void shouldMapDockerfile() {
void shouldMapContext() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.context = "example";
+ final var json = DevcontainerBuilder.builder().build(BuildBuilder.builder().context("example").create()).create();
// when
final var shellOptions = shellOptions(options, json);
// then
- assertEquals(json.context, shellOptions.context);
- }
-
- @Test
- @DisplayName("maps the build.dockerFile field")
- void shouldMapBuildDockerfile() {
- // given
- final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.build = new DevcontainerJson.Build();
- json.build.dockerFile = "some.dockerfile";
-
- // when
- final var shellOptions = shellOptions(options, json);
-
- // then
- assertEquals(json.build.dockerFile, shellOptions.containerfile);
- }
-
- @Test
- @DisplayName("maps the build.context field")
- void shouldMapBuildContext() {
- // given
- final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.build = new DevcontainerJson.Build();
- json.build.context = "example";
-
- // when
- final var shellOptions = shellOptions(options, json);
-
- // then
- assertEquals(json.build.context, shellOptions.context);
- }
-
- @Test
- @DisplayName("uses the context field in case build.context is empty")
- void shouldFallbackToContext() {
- // given
- final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.context = "example";
-
- // when
- final var shellOptions = shellOptions(options, json);
-
- // then
- assertEquals(json.context, shellOptions.context);
+ assertEquals(json.build().context(), shellOptions.context);
}
@Test
@@ -128,8 +80,7 @@ void shouldFallbackToContext() {
void shouldMapForwardPorts() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.forwardPorts = List.of(123, 456);
+ final var json = DevcontainerBuilder.builder().forwardPorts(List.of("123", "456")).create();
// when
final var shellOptions = shellOptions(options, json);
@@ -143,7 +94,7 @@ void shouldMapForwardPorts() {
void shouldUseDefaultForMissingContext() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
+ final var json = DevcontainerBuilder.builder().create();
// when
final var shellOptions = shellOptions(options, json);
@@ -157,7 +108,7 @@ void shouldUseDefaultForMissingContext() {
void shouldUseDefaultForMissingDockerfile() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
+ final var json = DevcontainerBuilder.builder().create();
// when
final var shellOptions = shellOptions(options, json);
@@ -175,7 +126,7 @@ class ComposeOptionsMapper {
@Test
@DisplayName("returns non-null values")
void shouldReturnNonNullValues() {
- assertNotNull(composeOptions(new DevcontainerOptions(), new DevcontainerJson(), Paths.get(".")));
+ assertNotNull(composeOptions(new DevcontainerOptions(), DevcontainerBuilder.builder().create(), Paths.get(".")));
}
@Test
@@ -183,8 +134,7 @@ void shouldReturnNonNullValues() {
void shouldMapDockerComposeFile() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.dockerComposeFile = List.of("your-compose.yml");
+ final var json = DevcontainerBuilder.builder().dockerComposeFile(List.of("your-compose.yml")).create();
// when
final var composeOptions = composeOptions(options, json, Paths.get("."));
@@ -198,14 +148,13 @@ void shouldMapDockerComposeFile() {
void shouldMapService() {
// given
final var options = new DevcontainerOptions();
- final var json = new DevcontainerJson();
- json.service = "some-service";
+ final var json = DevcontainerBuilder.builder().service("some-service").create();
// when
final var composeOptions = composeOptions(options, json, Paths.get("."));
// then
- assertEquals(json.service, composeOptions.service);
+ assertEquals(json.service(), composeOptions.service);
}
}
diff --git a/src/test/java/wtf/metio/ilo/devfile/DevfileTest.java b/src/test/java/wtf/metio/ilo/devfile/DevfileCommandTest.java
similarity index 86%
rename from src/test/java/wtf/metio/ilo/devfile/DevfileTest.java
rename to src/test/java/wtf/metio/ilo/devfile/DevfileCommandTest.java
index 148002e4d..314c36b34 100644
--- a/src/test/java/wtf/metio/ilo/devfile/DevfileTest.java
+++ b/src/test/java/wtf/metio/ilo/devfile/DevfileCommandTest.java
@@ -14,8 +14,8 @@
import static org.junit.jupiter.api.Assertions.*;
-@DisplayName("Devfile")
-class DevfileTest {
+@DisplayName("DevfileCommand")
+class DevfileCommandTest {
@Test
void shouldSupportPredefinedImages() {
@@ -27,7 +27,7 @@ void shouldSupportPredefinedImages() {
component.container = container;
devfile.components = List.of(component);
- assertTrue(Devfile.hasSupportedDevfileConfiguration(devfile, "container"));
+ assertTrue(DevfileCommand.hasSupportedDevfileConfiguration(devfile, "container"));
}
@Test
@@ -42,7 +42,7 @@ void shouldSupportLocalDockerfile() {
component.image = image;
devfile.components = List.of(component);
- assertTrue(Devfile.hasSupportedDevfileConfiguration(devfile, "image"));
+ assertTrue(DevfileCommand.hasSupportedDevfileConfiguration(devfile, "image"));
}
@Test
@@ -60,7 +60,7 @@ void shouldNotSupportGitDockerfile() {
component.image = image;
devfile.components = List.of(component);
- assertFalse(Devfile.hasSupportedDevfileConfiguration(devfile, "image"));
+ assertFalse(DevfileCommand.hasSupportedDevfileConfiguration(devfile, "image"));
}
@Test
@@ -73,7 +73,7 @@ void shouldMapPredefinedImages() {
component.container = container;
devfile.components = List.of(component);
final var options = new DevfileOptions();
- final var shellOptions = Devfile.mapOptions(options, devfile);
+ final var shellOptions = DevfileCommand.mapOptions(options, devfile);
assertEquals("docker.io/library/maven:latest", shellOptions.image);
}
diff --git a/src/test/java/wtf/metio/ilo/os/PosixShellTest.java b/src/test/java/wtf/metio/ilo/os/PosixShellTest.java
index 9728ae326..9473fe98c 100644
--- a/src/test/java/wtf/metio/ilo/os/PosixShellTest.java
+++ b/src/test/java/wtf/metio/ilo/os/PosixShellTest.java
@@ -20,7 +20,7 @@
import static org.junit.jupiter.api.Assertions.*;
import static wtf.metio.ilo.os.ParameterExpansion.MATCHER_GROUP_NAME;
-@DisplayName("Bourne Shell")
+@DisplayName("Bourne ShellCommand")
class PosixShellTest {
@Nested
diff --git a/src/test/java/wtf/metio/ilo/shell/ShellTest.java b/src/test/java/wtf/metio/ilo/shell/ShellCommandTest.java
similarity index 98%
rename from src/test/java/wtf/metio/ilo/shell/ShellTest.java
rename to src/test/java/wtf/metio/ilo/shell/ShellCommandTest.java
index 7599a9d6d..7ab97b8d2 100644
--- a/src/test/java/wtf/metio/ilo/shell/ShellTest.java
+++ b/src/test/java/wtf/metio/ilo/shell/ShellCommandTest.java
@@ -21,11 +21,11 @@
import static org.junit.jupiter.api.Assertions.*;
-@DisplayName("Shell")
+@DisplayName("ShellCommand")
@ExtendWith(SystemStubsExtension.class)
-class ShellTest extends TestMethodSources {
+class ShellCommandTest extends TestMethodSources {
- private Shell shell;
+ private ShellCommand shell;
private TestShellExecutor executor;
private ShellOptions options;
@@ -36,7 +36,7 @@ void setUp() {
options.missingVolumes = ShellVolumeBehavior.CREATE;
options.workingDir = "some/dir";
options.image = "fedora:latest";
- shell = new Shell(executor);
+ shell = new ShellCommand(executor);
shell.options = options;
}
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/compose/.devcontainer.json b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/compose/.devcontainer.json
deleted file mode 100644
index 908b3ab9c..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/compose/.devcontainer.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "dockerComposeFile": "some-file.yml",
- "service": "dev",
- "name": "my-name",
- "runServices": [
- "first",
- "second"
- ]
-}
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/directory/.devcontainer.json/.gitkeep b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/directory/.devcontainer.json/.gitkeep
deleted file mode 100644
index db3d1397f..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/directory/.devcontainer.json/.gitkeep
+++ /dev/null
@@ -1 +0,0 @@
-# folder is used by test
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/nested/.devcontainer/devcontainer.json b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/nested/.devcontainer/devcontainer.json
deleted file mode 100644
index 63568f60d..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/nested/.devcontainer/devcontainer.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "image": "example:123"
-}
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/not-found/nothing-here b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/not-found/nothing-here
deleted file mode 100644
index dbb8f381f..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/not-found/nothing-here
+++ /dev/null
@@ -1 +0,0 @@
-some random file which does not matter
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/root/.devcontainer.json b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/root/.devcontainer.json
deleted file mode 100644
index 63568f60d..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/root/.devcontainer.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "image": "example:123"
-}
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell-small/.devcontainer.json b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell-small/.devcontainer.json
deleted file mode 100644
index 63568f60d..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell-small/.devcontainer.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "image": "example:123"
-}
\ No newline at end of file
diff --git a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell/.devcontainer.json b/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell/.devcontainer.json
deleted file mode 100644
index 95e640e4d..000000000
--- a/src/test/resources/wtf/metio/ilo/devcontainer/DevcontainerJsonParser/shell/.devcontainer.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "image": "example:123",
- "dockerFile": "my.dockerfile",
- "remoteUser": "testUser",
- "containerUser": "root",
- "remoteEnv": {
- "key": "value"
- },
- "containerEnv": {
- "CI": "yes"
- },
- "runArgs": [
- "--pull"
- ],
- "workspaceFolder": "/home/testUser/project",
- "forwardPorts": [
- 12345,
- 9876
- ],
- "overrideCommand": true,
- "build": {
- "dockerFile": "other.dockerfile",
- "context": ".",
- "target": "dev",
- "args": {
- "some": "value"
- }
- }
-}
\ No newline at end of file