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

feat(catalog): Added Kamelet Configuration schema to Entities Catalog #857

Merged
merged 2 commits into from
Feb 22, 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 @@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -111,7 +112,7 @@ public void execute() {
var index = new Index();
var yamlDslSchemaProcessor = processCamelSchema(path, index);
processK8sSchema(path, index);
processCatalog(yamlDslSchemaProcessor, index);
processCatalog(yamlDslSchemaProcessor, path, index);
processCRDs(path, index);
processKamelets(path, index);
processAdditionalSchemas(path, index);
Expand Down Expand Up @@ -213,12 +214,26 @@ private void processK8sSchema(Path inputDir, Index index) {
}
}

private void processCatalog(CamelYamlDslSchemaProcessor schemaProcessor, Index index) {
private void processCatalog(CamelYamlDslSchemaProcessor schemaProcessor, Path inputDir, Index index) {
var catalogProcessor = new CamelCatalogProcessor(jsonMapper, schemaProcessor);
try {
var catalogMap = catalogProcessor.processCatalog();
catalogMap.forEach((name, catalog) -> {
try {
// Adding Kamelet Configuration Schema to the Entities Catalog
if (name == "entities") {
var catalogNode = jsonMapper.readTree(catalog);
var schema = inputDir.resolve("schema").resolve("KameletConfiguration.json");
((ObjectNode) catalogNode).putObject("KameletConfiguration").putObject("propertiesSchema");
((ObjectNode) catalogNode.path("KameletConfiguration").path("propertiesSchema"))
.setAll((ObjectNode) jsonMapper.readTree(schema.toFile()));

StringWriter writer = new StringWriter();
var jsonGenerator = new JsonFactory().createGenerator(writer).useDefaultPrettyPrinter();
jsonMapper.writeTree(jsonGenerator, catalogNode);
catalog = writer.toString();
}

var outputFileName = String.format(
"%s-%s-%s.json", CAMEL_CATALOG_AGGREGATE, name, Util.generateHash(catalog));
var output = outputDirectory.toPath().resolve(outputFileName);
Expand Down
Loading