From cff8585e1cec0649c8188ea8ba8d68f96727307a Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 16 Oct 2024 07:25:05 +0200 Subject: [PATCH 1/2] added inspect validation Signed-off-by: munishchouhan --- app/src/main/java/io/seqera/wave/cli/App.java | 3 +++ .../groovy/io/seqera/wave/cli/AppTest.groovy | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) 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 0ff7192..5a4772b 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -348,6 +348,9 @@ protected void validateArgs() { if( singularity && !freeze ) throw new IllegalCliArgumentException("Singularity build requires enabling freeze mode"); + if( inspect && isEmpty(image) ) + throw new IllegalCliArgumentException("Option --inspect requires the use of container image (--image)"); + if( !isEmpty(contextDir) ) { // check that a container file has been provided if( isEmpty(containerFile) ) 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 83e31d8..8786e59 100644 --- a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy +++ b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy @@ -585,4 +585,20 @@ class AppTest extends Specification { '2.0.0' | '2.1.0' | '2.0.0 (required: 2.1.0)' } + def 'should fail when inspecting without container image' () { + given: + def app = new App() + String[] args = ["--conda-package", "bwa", "--freeze", "--singularity", "--inspect"] + + when: + def cli = new CommandLine(app) + cli.parseArgs(args) + and: + app.validateArgs() + then: + def e = thrown(IllegalCliArgumentException) + and: + e.getMessage() == "Option --inspect requires the use of container image (--image)" + } + } From cd9eebe468467145ea568de311427863293e3f15 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Thu, 17 Oct 2024 14:14:28 +0200 Subject: [PATCH 2/2] moved validateArgs to main Signed-off-by: munishchouhan --- app/src/main/java/io/seqera/wave/cli/App.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 5a4772b..2f193c5 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -241,6 +241,8 @@ else if( result.isVersionHelpRequested() ) { app.setLogLevel(); app.defaultArgs(); + // validate the command line args + app.validateArgs(); if( app.info ) { app.printInfo(); } @@ -435,8 +437,6 @@ public void inspect() { @Override public void run() { - // validate the command line args - validateArgs(); // prepare the request buildContext = prepareContext(); containerConfig = prepareConfig();