31
31
import java .nio .file .NoSuchFileException ;
32
32
import java .nio .file .Path ;
33
33
import java .time .OffsetDateTime ;
34
- import java .util .Arrays ;
35
- import java .util .Base64 ;
36
- import java .util .List ;
37
- import java .util .Optional ;
34
+ import java .util .*;
38
35
import java .util .stream .Collectors ;
39
36
40
37
import ch .qos .logback .classic .Level ;
60
57
import io .seqera .wave .util .Packer ;
61
58
import org .slf4j .LoggerFactory ;
62
59
import picocli .CommandLine ;
63
- import static io . seqera . wave . cli . util . Checkers . isEmpty ;
64
- import static io .seqera .wave .cli .util .Checkers .isEnvVar ;
60
+
61
+ import static io .seqera .wave .cli .util .Checkers .* ;
65
62
import static io .seqera .wave .util .DockerHelper .addPackagesToSpackFile ;
66
63
import static io .seqera .wave .util .DockerHelper .condaFileFromPackages ;
67
64
import static io .seqera .wave .util .DockerHelper .condaFileFromPath ;
@@ -200,6 +197,9 @@ public class App implements Runnable {
200
197
@ Option (names = {"--include" }, paramLabel = "false" , description = "Include one or more containers in the specified base image" )
201
198
List <String > includes ;
202
199
200
+ @ Option (names = {"--label" }, paramLabel = "false" , description = "Include one or more labels in the wave build image. e.g. KEY=VALUE" )
201
+ List <String > label ;
202
+
203
203
public static void main (String [] args ) {
204
204
try {
205
205
final App app = new App ();
@@ -382,13 +382,28 @@ protected void validateArgs() {
382
382
if ( !isEmpty (platform ) && !VALID_PLATFORMS .contains (platform ) )
383
383
throw new IllegalCliArgumentException (String .format ("Unsupported container platform: '%s'" , platform ));
384
384
385
+ // check labels
386
+ if ( label !=null ) {
387
+ for ( String it : label ) {
388
+ if ( !isLabel (it ) ) throw new IllegalCliArgumentException ("Invalid docker label syntax - offending value: " + it );
389
+ }
390
+ }
391
+
385
392
}
386
393
387
394
protected Client client () {
388
395
return new Client ().withEndpoint (waveEndpoint );
389
396
}
390
397
391
398
protected SubmitContainerTokenRequest createRequest () {
399
+ Map <String , String > labels = null ;
400
+ if (label !=null ){
401
+ labels = new HashMap <>();
402
+ for (String singleLabel : label ){
403
+ String [] singleLabelArray = singleLabel .split ("=" );
404
+ labels .put (singleLabelArray [0 ], singleLabelArray [1 ]);
405
+ }
406
+ }
392
407
return new SubmitContainerTokenRequest ()
393
408
.withContainerImage (image )
394
409
.withContainerFile (containerFileBase64 ())
@@ -407,6 +422,7 @@ protected SubmitContainerTokenRequest createRequest() {
407
422
.withFreezeMode (freeze )
408
423
.withDryRun (dryRun )
409
424
.withContainerIncludes (includes )
425
+ .withLabels (labels )
410
426
;
411
427
}
412
428
0 commit comments