diff --git a/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java b/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java index 3cb24fc8..ddb28055 100644 --- a/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java +++ b/onyxia-api/src/test/java/fr/insee/onyxia/api/dao/universe/CatalogLoaderTest.java @@ -7,13 +7,16 @@ import fr.insee.onyxia.api.configuration.CatalogWrapper; import fr.insee.onyxia.api.configuration.CustomObjectMapper; import fr.insee.onyxia.api.util.TestUtils; +import fr.insee.onyxia.model.helm.Chart; import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.CollectionUtils; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = {CatalogLoader.class, CustomObjectMapper.class}) @@ -49,6 +52,27 @@ public void excludeChartTest() { .noneMatch(p -> p.getName().equalsIgnoreCase("excludeme"))); } + @Test + public void loadMaintainers() { + CatalogWrapper cw = new CatalogWrapper(); + cw.setType("helm"); + cw.setLocation("classpath:/catalog-loader-test"); + cw.setExcludedCharts(List.of("excludemetoo", "excludeme")); + catalogLoader.updateCatalog(cw); + List> maintainers = + cw.getCatalog().getPackages().stream() + .map(p -> ((Chart) p).getMaintainers()) + .collect(Collectors.toList()); + assertThat( + "Maintainers have been loaded", + maintainers.stream() + .filter(l -> !CollectionUtils.isEmpty(l)) + .anyMatch( + l -> + l.get(0).getName().equals("test") + && l.get(0).getEmail().equals("test@example.com"))); + } + @DisplayName( "Given a helm catalog wrapper with local charts and excluded charts, " + "when we update the catalog, " diff --git a/onyxia-api/src/test/resources/catalog-loader-test/index.yaml b/onyxia-api/src/test/resources/catalog-loader-test/index.yaml index 807192e0..c0b74a06 100644 --- a/onyxia-api/src/test/resources/catalog-loader-test/index.yaml +++ b/onyxia-api/src/test/resources/catalog-loader-test/index.yaml @@ -1,93 +1,96 @@ apiVersion: v1 entries: keepme: - - apiVersion: v2 - appVersion: "1" - created: "2022-10-03T11:53:20.589754116Z" - dependencies: - - name: argo-cd - repository: https://argoproj.github.io/argo-helm - version: 4.9.11 - - name: library-chart - repository: https://inseefrlab.github.io/helm-charts-datascience - version: 2.0.21 - description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. - digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd - home: https://argo-cd.readthedocs.io/en/stable/ - icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png - name: keepme - sources: - - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd - - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd - type: application - urls: - - keepeme1.gz - version: 2.4.0 - - apiVersion: v2 - appVersion: "2" - created: "2022-10-03T11:53:20.589754116Z" - dependencies: - - name: argo-cd - repository: https://argoproj.github.io/argo-helm - version: 4.9.11 - - name: library-chart - repository: https://inseefrlab.github.io/helm-charts-datascience - version: 2.0.21 - description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. - digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd - home: https://argo-cd.readthedocs.io/en/stable/ - icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png - name: keepme - sources: - - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd - - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd - type: application - urls: - - keepeme2.gz - version: 2.4.0 + - apiVersion: v2 + appVersion: "1" + created: "2022-10-03T11:53:20.589754116Z" + dependencies: + - name: argo-cd + repository: https://argoproj.github.io/argo-helm + version: 4.9.11 + - name: library-chart + repository: https://inseefrlab.github.io/helm-charts-datascience + version: 2.0.21 + description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. + digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd + home: https://argo-cd.readthedocs.io/en/stable/ + icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png + name: keepme + sources: + - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd + - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd + type: application + urls: + - keepeme1.gz + version: 2.4.0 + maintainers: + - email: test@example.com + name: test + - apiVersion: v2 + appVersion: "2" + created: "2022-10-03T11:53:20.589754116Z" + dependencies: + - name: argo-cd + repository: https://argoproj.github.io/argo-helm + version: 4.9.11 + - name: library-chart + repository: https://inseefrlab.github.io/helm-charts-datascience + version: 2.0.21 + description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. + digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd + home: https://argo-cd.readthedocs.io/en/stable/ + icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png + name: keepme + sources: + - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd + - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd + type: application + urls: + - keepeme2.gz + version: 2.4.0 excludeme: - - apiVersion: v2 - appVersion: "1" - created: "2022-10-03T11:53:20.589754116Z" - dependencies: - - name: argo-cd - repository: https://argoproj.github.io/argo-helm - version: 4.9.11 - - name: library-chart - repository: https://inseefrlab.github.io/helm-charts-datascience - version: 2.0.21 - description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. - digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd - home: https://argo-cd.readthedocs.io/en/stable/ - icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png - name: excludeme - sources: - - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd - - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd - type: application - urls: - - excludeme1.gz - version: 2.4.0 - - apiVersion: v2 - appVersion: "2" - created: "2022-10-03T11:53:20.589754116Z" - dependencies: - - name: argo-cd - repository: https://argoproj.github.io/argo-helm - version: 4.9.11 - - name: library-chart - repository: https://inseefrlab.github.io/helm-charts-datascience - version: 2.0.21 - description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. - digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd - home: https://argo-cd.readthedocs.io/en/stable/ - icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png - name: excludeme - sources: - - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd - - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd - type: application - urls: - - excludeme2.gz - version: 2.4.0 + - apiVersion: v2 + appVersion: "1" + created: "2022-10-03T11:53:20.589754116Z" + dependencies: + - name: argo-cd + repository: https://argoproj.github.io/argo-helm + version: 4.9.11 + - name: library-chart + repository: https://inseefrlab.github.io/helm-charts-datascience + version: 2.0.21 + description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. + digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd + home: https://argo-cd.readthedocs.io/en/stable/ + icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png + name: excludeme + sources: + - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd + - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd + type: application + urls: + - excludeme1.gz + version: 2.4.0 + - apiVersion: v2 + appVersion: "2" + created: "2022-10-03T11:53:20.589754116Z" + dependencies: + - name: argo-cd + repository: https://argoproj.github.io/argo-helm + version: 4.9.11 + - name: library-chart + repository: https://inseefrlab.github.io/helm-charts-datascience + version: 2.0.21 + description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. + digest: beedc71c7f5730cf68000b5665dd4da636e72a026edd9b12c1d048398d4166dd + home: https://argo-cd.readthedocs.io/en/stable/ + icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/argo.png + name: excludeme + sources: + - https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/argo-cd + - https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd + type: application + urls: + - excludeme2.gz + version: 2.4.0 diff --git a/onyxia-api/src/test/resources/multiverse.json b/onyxia-api/src/test/resources/multiverse.json deleted file mode 100644 index 789411e8..00000000 --- a/onyxia-api/src/test/resources/multiverse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "catalogs": [ - { - "id": "inseefrlab-kub", - "name": "Datascience", - "description": "Services for datascientists. https://github.com/InseeFrLab/Universe-Datascience", - "maintainer": "innovation@insee.fr", - "location": "classpath:sample-helm.yaml", - "status": "PROD", - "type": "helm" - } - ] -} diff --git a/onyxia-api/src/test/resources/sample-helm.yaml b/onyxia-api/src/test/resources/sample-helm.yaml deleted file mode 100644 index 43b43ff8..00000000 --- a/onyxia-api/src/test/resources/sample-helm.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -apiVersion: v1 -entries: - httpbin: - - apiVersion: v2 - appVersion: latest - created: "2020-03-27T22:46:19.283017399Z" - description: A Helm chart for Kubernetes - digest: dc063676787ff6116aa07963c3e3776f7ce0320ede77bc72f29b8c3835ec47e4 - name: httpbin - type: application - urls: - - https://github.com/InseeFrLab/helm-charts/releases/download/httpbin-1.1/httpbin-1.1.tgz - version: "1.1" -generated: "2020-03-27T22:46:19.192701581Z" diff --git a/onyxia-model/src/main/java/fr/insee/onyxia/model/helm/Chart.java b/onyxia-model/src/main/java/fr/insee/onyxia/model/helm/Chart.java index e8675717..02e1cd42 100644 --- a/onyxia-model/src/main/java/fr/insee/onyxia/model/helm/Chart.java +++ b/onyxia-model/src/main/java/fr/insee/onyxia/model/helm/Chart.java @@ -249,7 +249,7 @@ public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } - private class Maintainer { + public static class Maintainer { @JsonProperty("email") private String email;