diff --git a/app/src/main/java/io/seqera/wave/cli/App.java b/app/src/main/java/io/seqera/wave/cli/App.java index bfabd84..a194be1 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -199,6 +199,9 @@ public class App implements Runnable { @Option(names = {"--include"}, paramLabel = "false", description = "Include one or more containers in the specified base image") List includes; + @Option(names = {"--image-name"}, paramLabel = "false", description = "Overrides wave generated container image name") + String imageName; + public static void main(String[] args) { try { final App app = new App(); @@ -380,6 +383,11 @@ protected void validateArgs() { if( !isEmpty(platform) && !VALID_PLATFORMS.contains(platform) ) throw new IllegalCliArgumentException(String.format("Unsupported container platform: '%s'", platform)); + // Check if imageName is not empty + if( imageName != null ){ + if( "".equals(imageName.trim()) ) throw new IllegalCliArgumentException("The --image-name cannot be an empty string"); + } + } protected Client client() { @@ -405,7 +413,7 @@ protected SubmitContainerTokenRequest createRequest() { .withFreezeMode(freeze) .withDryRun(dryRun) .withContainerIncludes(includes) - ; + .withImageName(imageName); } public void inspect() { diff --git a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy index 8cd647d..f816b8d 100644 --- a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy +++ b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy @@ -269,4 +269,21 @@ class AppTest extends Specification { app.@towerToken == 'xyz' } + def 'should add imageName' () { + given: + def app = new App() + String[] args = [ '-f', 'Dockerfile','--image-name', "foo"] + + when: + new CommandLine(app).parseArgs(args) + and: + app.validateArgs() + + then: + noExceptionThrown() + and: + app.@containerFile == 'Dockerfile' + app.@imageName == 'foo' + } + }