Skip to content

Commit

Permalink
Cleanup unused logic (#456)
Browse files Browse the repository at this point in the history
Co-authored-by: Comte <[email protected]>
  • Loading branch information
olevitt and fcomte authored Jul 15, 2024
1 parent dcbd64d commit 66ed9c1
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 1,234 deletions.
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,13 @@ 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")));
}
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 66ed9c1

Please sign in to comment.