Skip to content

Commit

Permalink
Merge branch 'main' into ssb
Browse files Browse the repository at this point in the history
  • Loading branch information
johnksv committed Aug 1, 2024
2 parents 0237cc6 + a86e85e commit 4324d18
Show file tree
Hide file tree
Showing 37 changed files with 471 additions and 1,332 deletions.
61 changes: 36 additions & 25 deletions docs/region-configuration.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helm-wrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
</dependencies>

Expand Down
6 changes: 3 additions & 3 deletions onyxia-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM eclipse-temurin:21.0.3_9-jre as extract
FROM eclipse-temurin:21.0.4_7-jre as extract
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:21.0.3_9-jre
FROM eclipse-temurin:21.0.4_7-jre
WORKDIR /app
# Install helm
RUN curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | DESIRED_VERSION=v3.14.2 bash
RUN curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | DESIRED_VERSION=v3.15.3 bash
RUN groupadd --gid 101 --system onyxia && \
useradd --system --uid 101 --create-home --home-dir /var/cache/onyxia --shell /sbin/nologin --gid onyxia --comment onyxia onyxia
# Allow adding CA certificates
Expand Down
4 changes: 2 additions & 2 deletions onyxia-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -91,7 +91,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.25.0</version>
<version>1.26.2</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class CatalogWrapper {
@Schema(description = "Catalog id")
private String id;

@Schema(description = "Catalog name")
private String name;
@Schema(description = "Localized string for the name of the catalog")
private Object name;

@Schema(description = "Description of the catalog")
private String description;
@Schema(description = "Localized string for the description of the catalog")
private Object description;

@Schema(description = "Who maintains the catalog")
private String maintainer;
Expand Down Expand Up @@ -127,11 +127,11 @@ public void setId(String id) {
this.id = id;
}

public String getName() {
public Object getName() {
return name;
}

public void setName(String name) {
public void setName(Object name) {
this.name = name;
}

Expand All @@ -143,11 +143,11 @@ public void setLocation(String location) {
this.location = location;
}

public String getDescription() {
public Object getDescription() {
return description;
}

public void setDescription(String description) {
public void setDescription(Object description) {
this.description = description;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fr.insee.onyxia.api.controller.exception.OnboardingDisabledException;
import fr.insee.onyxia.api.services.UserProvider;
import fr.insee.onyxia.api.services.impl.kubernetes.KubernetesService;
import fr.insee.onyxia.model.User;
import fr.insee.onyxia.model.region.Region;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -58,14 +59,15 @@ public void onboard(

checkPermissions(region, request);
final KubernetesService.Owner owner = new KubernetesService.Owner();
final User user = userProvider.getUser(region);
if (request.getGroup() != null) {
owner.setId(request.getGroup());
owner.setType(KubernetesService.Owner.OwnerType.GROUP);
} else {
owner.setId(userProvider.getUser(region).getIdep());
owner.setId(user.getIdep());
owner.setType(KubernetesService.Owner.OwnerType.USER);
}
kubernetesService.createDefaultNamespace(region, owner);
kubernetesService.createOrUpdateNamespace(region, owner, user);
}

private void checkPermissions(Region region, OnboardingRequest request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@
import fr.insee.onyxia.api.configuration.Catalogs;
import fr.insee.onyxia.api.configuration.NotFoundException;
import fr.insee.onyxia.api.services.CatalogService;
import fr.insee.onyxia.model.catalog.Config.Property;
import fr.insee.onyxia.model.catalog.Config.Property.XForm;
import fr.insee.onyxia.model.catalog.Config.Property.XOnyxia;
import fr.insee.onyxia.model.catalog.Pkg;
import fr.insee.onyxia.model.helm.Chart;
import fr.insee.onyxia.model.region.Region;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -82,7 +77,6 @@ public Pkg getPackage(@PathVariable String catalogId, @PathVariable String packa
catalogService
.getPackage(catalogId, packageName)
.orElseThrow(NotFoundException::new);
addCustomOnyxiaProperties(pkg);
return pkg;
}

Expand Down Expand Up @@ -116,7 +110,6 @@ public Chart getChartByVersion(
catalogService
.getChartByVersion(catalogId, chartName, version)
.orElseThrow(NotFoundException::new);
addCustomOnyxiaProperties(chart);
return chart;
}

Expand All @@ -140,57 +133,6 @@ public Chart getChartByVersion(
public List<Chart> getCharts(@PathVariable String catalogId, @PathVariable String chartName) {
List<Chart> charts =
catalogService.getCharts(catalogId, chartName).orElseThrow(NotFoundException::new);
charts.forEach(this::addCustomOnyxiaProperties);
return charts;
}

private void addCustomOnyxiaProperties(Pkg pkg) {
Map<String, Property> properties = pkg.getConfig().getProperties().getProperties();
Property property = new Property();
property.setDescription("Onyxia specific configuration");
property.setType("object");
property.setProperties(new HashMap<>());
Map<String, Property> onyxiaProperties = new HashMap<>();
Property customName = new Property();
String stringType = "string";
customName.setType(stringType);
customName.setDescription("Service custom name");
customName.setDefaut(pkg.getName());
customName.setTitle("Custom name");
onyxiaProperties.put("friendlyName", customName);
Property userDefinedValues = new Property();
userDefinedValues.setType(stringType);
userDefinedValues.setDescription("Values defined by the end user");
userDefinedValues.setDefaut("");
userDefinedValues.setTitle("User defined values");
XOnyxia xonyxiaUserDefinedValues = new XOnyxia();
xonyxiaUserDefinedValues.setHidden(true);
userDefinedValues.setXonyxia(xonyxiaUserDefinedValues);
onyxiaProperties.put("userDefinedValues", userDefinedValues);
Property owner = new Property();
owner.setType(stringType);
owner.setDescription("Owner of the chart");
owner.setDefaut("owner");
owner.setTitle("Owner");
XForm xform = new XForm();
xform.setValue("{{user.idep}}");
xform.setHidden(true);
owner.setXform(xform);
XOnyxia xonyxia = new XOnyxia();
xonyxia.setOverwriteDefaultWith("{{user.idep}}");
xonyxia.setHidden(true);
owner.setXonyxia(xonyxia);
onyxiaProperties.put("owner", owner);

Property share = new Property();
share.setType("boolean");
share.setDescription("Enable share for this service");
share.setDefaut(false);
share.setTitle("Share");
onyxiaProperties.put("share", share);

property.setProperties(onyxiaProperties);

properties.put("onyxia", property);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.zafarkhaja.semver.Version;
import fr.insee.onyxia.api.configuration.CatalogWrapper;
import fr.insee.onyxia.model.catalog.Config.Config;
import fr.insee.onyxia.model.catalog.Pkg;
import fr.insee.onyxia.model.helm.Chart;
import fr.insee.onyxia.model.helm.Repository;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -186,8 +186,25 @@ public void extractDataFromTgz(InputStream in, Chart chart) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Config config = mapper.readValue(tarIn, Config.class);
chart.setConfig(config);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = tarIn.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
chart.setConfig(mapper.readTree(baos.toString("UTF-8")));
}
if (entry.getName().endsWith(chart.getName() + "/values.yaml")
&& !entry.getName()
.endsWith("charts/" + chart.getName() + "/values.yaml")) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = tarIn.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
byte[] fileContent = baos.toByteArray();
chart.setDefaultValues(new String(fileContent));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class InstallServiceEvent extends OnyxiaEvent {
private String namespace;
private String releaseName;
private String packageName;
private String friendlyName;

public String getReleaseName() {
return releaseName;
Expand All @@ -23,6 +24,14 @@ public void setPackageName(String packageName) {
this.packageName = packageName;
}

public String getFriendlyName() {
return friendlyName;
}

public void setFriendlyName(String friendlyName) {
this.friendlyName = friendlyName;
}

private String username;
private String catalogId;

Expand All @@ -33,12 +42,14 @@ public InstallServiceEvent(
String namespace,
String releaseName,
String packageName,
String catalogId) {
String catalogId,
String friendlyName) {
this.namespace = namespace;
this.releaseName = releaseName;
this.catalogId = catalogId;
this.username = username;
this.packageName = packageName;
this.friendlyName = friendlyName;
}

public String getUsername() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public SuspendResumeServiceEvent(
String packageName,
String catalogId,
boolean suspend) {
super(username, namespace, releaseName, packageName, catalogId);
super(username, namespace, releaseName, packageName, catalogId, null);
this.isSuspend = suspend;
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4324d18

Please sign in to comment.