Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions wave-api/src/main/java/io/seqera/wave/api/PackagesSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Objects;

import io.seqera.wave.config.CondaOpts;
import io.seqera.wave.config.PixiOpts;

/**
* Model a Package environment requirements
Expand Down Expand Up @@ -48,6 +49,11 @@ public enum Type { CONDA }
*/
public CondaOpts condaOpts;

/**
* Pixi build options
*/
public PixiOpts pixiOpts;

/**
* channels used for downloading packages
*/
Expand All @@ -62,6 +68,7 @@ public boolean equals(Object object) {
&& Objects.equals(environment, that.environment)
&& Objects.equals(entries, that.entries)
&& Objects.equals(condaOpts, that.condaOpts)
&& Objects.equals(pixiOpts, that.pixiOpts)
&& Objects.equals(channels, that.channels);
}

Expand All @@ -77,6 +84,7 @@ public String toString() {
", envFile='" + environment + '\'' +
", packages=" + entries +
", condaOpts=" + condaOpts +
", pixiOpts=" + pixiOpts +
", channels=" + ObjectUtils.toString(channels) +
'}';
}
Expand Down Expand Up @@ -106,4 +114,8 @@ public PackagesSpec withCondaOpts(CondaOpts opts) {
return this;
}

public PackagesSpec withPixiOpts(PixiOpts opts) {
this.pixiOpts = opts;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class SubmitContainerTokenRequest implements Cloneable {
public String workflowId;

/**
* One or more container should be included in upstream container request
* One or more container should be included in the upstream container request
*/
public List<String> containerIncludes;

Expand All @@ -150,7 +150,7 @@ public class SubmitContainerTokenRequest implements Cloneable {
public ScanMode scanMode;

/**
* Define the allows security vulnerabilities in the container request.
* Define the allowed security vulnerabilities in the container request.
* Empty or null means no vulnerabilities are allowed.
*/
public List<ScanLevel> scanLevels;
Expand All @@ -160,6 +160,11 @@ public class SubmitContainerTokenRequest implements Cloneable {
*/
public BuildCompression buildCompression;

/**
* The build template that should be used to build the container image.
*/
public String buildTemplate;

public SubmitContainerTokenRequest copyWith(Map opts) {
try {
final SubmitContainerTokenRequest copy = (SubmitContainerTokenRequest) this.clone();
Expand Down Expand Up @@ -213,6 +218,8 @@ public SubmitContainerTokenRequest copyWith(Map opts) {
copy.scanLevels = (List<ScanLevel>) opts.get("scanLevels");
if( opts.containsKey("buildCompression"))
copy.buildCompression = (BuildCompression) opts.get("buildCompression");
if( opts.containsKey("buildTemplate"))
copy.buildTemplate = (String) opts.get("buildTemplate");
// done
return copy;
}
Expand Down Expand Up @@ -353,6 +360,11 @@ public SubmitContainerTokenRequest withBuildCompression(BuildCompression mode) {
return this;
}

public SubmitContainerTokenRequest withBuildTemplate(String template) {
this.buildTemplate = template;
return this;
}

public boolean formatSingularity() {
return "sif".equals(format);
}
Expand Down Expand Up @@ -385,6 +397,7 @@ public String toString() {
", scanMode=" + scanMode +
", scanLevels=" + scanLevels +
", buildCompression=" + buildCompression +
", buildTemplate=" + buildTemplate +
'}';
}
}
21 changes: 17 additions & 4 deletions wave-api/src/main/java/io/seqera/wave/config/CondaOpts.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@
*/
public class CondaOpts {
final public static String DEFAULT_MAMBA_IMAGE = "mambaorg/micromamba:1.5.10-noble";
final public static String DEFAULT_MAMBA_IMAGE_V2 = "mambaorg/micromamba:2.1.1";
final public static String DEFAULT_PACKAGES = "conda-forge::procps-ng";
final public static String DEFAULT_BASE_IMAGE = "ubuntu:24.04";

public String mambaImage;
public List<String> commands;
public String basePackages;
public String baseImage;

static public CondaOpts v2() {
return new CondaOpts(Map.of("mambaImage", DEFAULT_MAMBA_IMAGE_V2));
}

public CondaOpts() {
this(Map.of());
Expand All @@ -41,6 +48,7 @@ public CondaOpts(Map<String,?> opts) {
this.mambaImage = opts.containsKey("mambaImage") ? opts.get("mambaImage").toString(): DEFAULT_MAMBA_IMAGE;
this.commands = opts.containsKey("commands") ? (List<String>)opts.get("commands") : null;
this.basePackages = opts.containsKey("basePackages") ? (String)opts.get("basePackages") : DEFAULT_PACKAGES;
this.baseImage = opts.containsKey("baseImage") ? opts.get("baseImage").toString(): DEFAULT_BASE_IMAGE;
}

public CondaOpts withMambaImage(String value) {
Expand All @@ -60,10 +68,11 @@ public CondaOpts withBasePackages(String value) {

@Override
public String toString() {
return String.format("CondaOpts(mambaImage=%s; basePackages=%s, commands=%s)",
return String.format("CondaOpts(mambaImage=%s; basePackages=%s, commands=%s, baseImage=%s)",
mambaImage,
basePackages,
commands != null ? String.join(",", commands) : "null"
commands != null ? String.join(",", commands) : "null",
baseImage
);
}

Expand All @@ -72,11 +81,15 @@ public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
CondaOpts condaOpts = (CondaOpts) object;
return Objects.equals(mambaImage, condaOpts.mambaImage) && Objects.equals(commands, condaOpts.commands) && Objects.equals(basePackages, condaOpts.basePackages);
return Objects.equals(mambaImage, condaOpts.mambaImage)
&& Objects.equals(commands, condaOpts.commands)
&& Objects.equals(basePackages, condaOpts.basePackages)
&& Objects.equals(baseImage, condaOpts.baseImage)
;
}

@Override
public int hashCode() {
return Objects.hash(mambaImage, commands, basePackages);
return Objects.hash(mambaImage, commands, basePackages, baseImage);
}
}
91 changes: 91 additions & 0 deletions wave-api/src/main/java/io/seqera/wave/config/PixiOpts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Wave, containers provisioning service
* Copyright (c) 2023-2024, Seqera Labs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package io.seqera.wave.config;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* @author Paolo Di Tommaso <[email protected]>
*/
public class PixiOpts {

final public static String DEFAULT_PIXI_IMAGE = "ghcr.io/prefix-dev/pixi:latest";
final public static String DEFAULT_BASE_IMAGE = "ubuntu:24.04";
final public static String DEFAULT_PACKAGES = "conda-forge::procps-ng";

public String pixiImage;
public List<String> commands;
public String basePackages;
public String baseImage;

public PixiOpts() {
this(Map.of());
}
public PixiOpts(Map<String,?> opts) {
this.pixiImage = opts.containsKey("pixiImage") ? opts.get("pixiImage").toString(): DEFAULT_PIXI_IMAGE;
this.baseImage = opts.containsKey("baseImage") ? opts.get("baseImage").toString(): DEFAULT_BASE_IMAGE;
this.commands = opts.containsKey("commands") ? (List<String>)opts.get("commands") : null;
this.basePackages = opts.containsKey("basePackages") ? (String)opts.get("basePackages") : DEFAULT_PACKAGES;
}

public PixiOpts withMambaImage(String value) {
this.pixiImage = value;
return this;
}

public PixiOpts withCommands(List<String> value) {
this.commands = value;
return this;
}

public PixiOpts withBasePackages(String value) {
this.basePackages = value;
return this;
}

@Override
public String toString() {
return String.format("PixiOpts(pixiImage=%s; basePackages=%s, commands=%s, baseImage=%s)",
pixiImage,
basePackages,
commands != null ? String.join(",", commands) : "null",
baseImage
);
}

@Override
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
CondaOpts condaOpts = (CondaOpts) object;
return Objects.equals(pixiImage, condaOpts.mambaImage)
&& Objects.equals(commands, condaOpts.commands)
&& Objects.equals(basePackages, condaOpts.basePackages)
&& Objects.equals(baseImage, condaOpts.baseImage)
;
}

@Override
public int hashCode() {
return Objects.hash(pixiImage, commands, basePackages, baseImage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class SubmitContainerTokenRequestTest extends Specification {
scanMode: ScanMode.async,
scanLevels: List.of(ScanLevel.LOW, ScanLevel.MEDIUM),
buildCompression: BuildCompression.gzip,
buildTemplate: 'micromamba',
)

when:
Expand Down Expand Up @@ -81,6 +82,7 @@ class SubmitContainerTokenRequestTest extends Specification {
copy.scanMode == req.scanMode
copy.scanLevels == req.scanLevels
copy.buildCompression == req.buildCompression
copy.buildTemplate == req.buildTemplate
and:
copy.formatSingularity()

Expand Down Expand Up @@ -110,6 +112,7 @@ class SubmitContainerTokenRequestTest extends Specification {
scanMode: ScanMode.required,
scanLevels: List.of(ScanLevel.HIGH),
buildCompression: BuildCompression.estargz,
buildTemplate: 'pixi',
)
then:
other.towerAccessToken == 'b1'
Expand All @@ -135,6 +138,7 @@ class SubmitContainerTokenRequestTest extends Specification {
other.scanMode == ScanMode.required
other.scanLevels == List.of(ScanLevel.HIGH)
other.buildCompression == BuildCompression.estargz
other.buildTemplate == 'pixi'
and:
!other.formatSingularity()
}
Expand Down
Loading
Loading