Skip to content

Commit

Permalink
Added --image-name
Browse files Browse the repository at this point in the history
Signed-off-by: munishchouhan <hrma017@gmail.com>
  • Loading branch information
munishchouhan committed Feb 22, 2024
1 parent b47f31f commit 06dd399
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/src/main/java/io/seqera/wave/cli/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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();
Expand Down Expand Up @@ -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() {
Expand All @@ -405,7 +413,7 @@ protected SubmitContainerTokenRequest createRequest() {
.withFreezeMode(freeze)
.withDryRun(dryRun)
.withContainerIncludes(includes)
;
.withImageName(imageName);
}

public void inspect() {
Expand Down
17 changes: 17 additions & 0 deletions app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

}

0 comments on commit 06dd399

Please sign in to comment.