From 6358d0101f669ab04841ab04be2ea8a4a1de25a4 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 12 Apr 2025 21:08:30 -0400 Subject: [PATCH 1/2] Add support for build compression Signed-off-by: Paolo Di Tommaso --- app/build.gradle | 4 +-- app/src/main/java/io/seqera/wave/cli/App.java | 11 ++++++++ .../groovy/io/seqera/wave/cli/AppTest.groovy | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1affc5c..bd71483 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,8 +21,8 @@ repositories { } dependencies { - implementation 'io.seqera:wave-api:0.14.0' - implementation 'io.seqera:wave-utils:0.15.0' + implementation 'io.seqera:wave-api:0.16.0' + implementation 'io.seqera:wave-utils:0.15.1' implementation 'info.picocli:picocli:4.6.1' implementation 'com.squareup.moshi:moshi:1.15.2' implementation 'com.squareup.moshi:moshi-adapters:1.15.2' 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 dbb7eb2..053e568 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -197,6 +197,10 @@ public class App implements Runnable { @Option(names = {"--scan-level"}, paramLabel = "false", description = "Specify one or more security scan vulnerabilities level allowed in the container e.g. low,medium,high,critical") private List scanLevels; + @Option(names = {"--build-compression"}, paramLabel = "false", description = "Specify the compression algorithm to be used for the build context, it can be 'gzip', 'zstd' or 'estargz'") + private BuildCompression.Mode buildCompression; + + @CommandLine.Parameters List prompt; @@ -413,9 +417,16 @@ protected SubmitContainerTokenRequest createRequest() { .withMirror(mirror) .withScanMode(scanMode) .withScanLevels(scanLevels) + .withBuildCompression(compression(buildCompression)) ; } + BuildCompression compression(BuildCompression.Mode mode) { + if( mode==null ) + return null; + return new BuildCompression().withMode(mode); + } + public void inspect() { final Client client = client(); final ContainerInspectRequest req = new ContainerInspectRequest() 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 a1c16f9..daba55f 100644 --- a/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy +++ b/app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy @@ -21,6 +21,7 @@ import java.nio.file.Files import java.time.Duration import java.time.Instant +import io.seqera.wave.api.BuildCompression import io.seqera.wave.api.ContainerStatus import io.seqera.wave.api.ContainerStatusResponse import io.seqera.wave.api.ImageNameStrategy @@ -308,6 +309,32 @@ class AppTest extends Specification { req.scanLevels == List.of(ScanLevel.LOW, ScanLevel.MEDIUM) } + def 'should set build compression gzip' () { + given: + def app = new App() + String[] args = ["--build-compression", 'gzip'] + + when: + new CommandLine(app).parseArgs(args) + and: + def req = app.createRequest() + then: + req.buildCompression == new BuildCompression().withMode(BuildCompression.Mode.gzip) + } + + def 'should set build compression estargz' () { + given: + def app = new App() + String[] args = ["--build-compression", 'estargz'] + + when: + new CommandLine(app).parseArgs(args) + and: + def req = app.createRequest() + then: + req.buildCompression == new BuildCompression().withMode(BuildCompression.Mode.estargz) + } + def 'should not allow dry-run and await' () { given: def app = new App() From 480ba4cde939988e1fd0740c72a958ef6340e2d8 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Fri, 16 May 2025 16:22:20 -0400 Subject: [PATCH 2/2] Minor changes Signed-off-by: Paolo Di Tommaso --- app/conf/reflect-config.json | 9 +++++++++ app/src/main/java/io/seqera/wave/cli/App.java | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/conf/reflect-config.json b/app/conf/reflect-config.json index c22ba0a..ced7694 100644 --- a/app/conf/reflect-config.json +++ b/app/conf/reflect-config.json @@ -194,6 +194,15 @@ { "name":"groovy.lang.Closure" }, +{ + "name":"io.seqera.wave.api.BuildCompression", + "allDeclaredFields":true, + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"io.seqera.wave.api.BuildCompression$Mode", + "fields":[{"name":"estargz"}, {"name":"gzip"}, {"name":"zstd"}] +}, { "name":"io.seqera.wave.api.BuildContext", "allDeclaredFields":true, 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 053e568..96ecf6c 100644 --- a/app/src/main/java/io/seqera/wave/cli/App.java +++ b/app/src/main/java/io/seqera/wave/cli/App.java @@ -185,19 +185,19 @@ public class App implements Runnable { @Option(names = {"--include"}, paramLabel = "''", description = "Include one or more containers in the specified base image") private List includes; - @Option(names = {"--name-strategy"}, paramLabel = "false", description = "Specify the name strategy for the container name, it can be 'none' or 'tagPrefix' or 'imageSuffix'") + @Option(names = {"--name-strategy"}, paramLabel = "", description = "Specify the name strategy for the container name, it can be 'none' or 'tagPrefix' or 'imageSuffix'") private ImageNameStrategy nameStrategy; @Option(names = {"-m","--mirror"}, paramLabel = "false", description = "Enable container mirror mode'") private boolean mirror; - @Option(names = {"--scan-mode"}, paramLabel = "false", description = "Specify container security scan mode, it can be 'none', 'async' or 'required'") + @Option(names = {"--scan-mode"}, paramLabel = "", description = "Specify container security scan mode, it can be 'none', 'async' or 'required'") private ScanMode scanMode; - @Option(names = {"--scan-level"}, paramLabel = "false", description = "Specify one or more security scan vulnerabilities level allowed in the container e.g. low,medium,high,critical") + @Option(names = {"--scan-level"}, paramLabel = "", description = "Specify one or more security scan vulnerabilities level allowed in the container e.g. low,medium,high,critical") private List scanLevels; - @Option(names = {"--build-compression"}, paramLabel = "false", description = "Specify the compression algorithm to be used for the build context, it can be 'gzip', 'zstd' or 'estargz'") + @Option(names = {"--build-compression"}, paramLabel = "", description = "Specify the compression algorithm to be used for the build context, it can be 'gzip', 'zstd' or 'estargz'") private BuildCompression.Mode buildCompression;