Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(1472): sort kamelets alphabetically in the catalog #1539

Merged
merged 1 commit into from
Oct 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
var root = jsonMapper.createObjectNode();

try {
kamelets.forEach(kamelet -> {
sortKamelets(kamelets).forEach(kamelet -> {

Check warning on line 253 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java#L253

Added line #L253 was not covered by tests
processKameletFile(kamelet, root);
});

Expand Down Expand Up @@ -293,6 +293,22 @@
}
}

private List<String> sortKamelets(List<String> kamelets) {
return kamelets.stream().sorted(

Check warning on line 297 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java#L297

Added line #L297 was not covered by tests
(k1, k2) -> {
try {
JsonNode kameletNode1 = yamlMapper.readTree(k1);
JsonNode kameletNode2 = yamlMapper.readTree(k2);
String kamelet1 = kameletNode1.get("metadata").get("name").asText().toLowerCase();
String kamelet2 = kameletNode2.get("metadata").get("name").asText().toLowerCase();
return kamelet1.compareTo(kamelet2);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e);

Check warning on line 306 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java#L300-L306

Added lines #L300 - L306 were not covered by tests
}
return 0;
}).toList();

Check warning on line 309 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CatalogGenerator.java#L308-L309

Added lines #L308 - L309 were not covered by tests
}

private void processK8sSchema(CatalogDefinition index) {
if (camelCatalogVersionLoader.getKubernetesSchema() == null) {
LOGGER.severe("Kubernetes JSON Schema is not loaded");
Expand Down
Loading