use of io.kaoto.backend.model.deployment.kamelet.KameletBinding in project kaoto-backend by KaotoIO.
the class ClusterService method start.
public boolean start(final String input) {
try {
Yaml yaml = new Yaml(new Constructor(KameletBinding.class));
KameletBinding binding = yaml.load(input);
if (binding.getMetadata() == null) {
binding.setMetadata(new ObjectMeta());
}
final var name = binding.getMetadata().getName();
if (name == null || name.isEmpty()) {
binding.getMetadata().setName("integration-" + System.currentTimeMillis());
}
return start(binding);
} catch (ConstructorException e) {
log.warn("Error starting the integration.", e);
return false;
}
}
use of io.kaoto.backend.model.deployment.kamelet.KameletBinding in project kaoto-backend by KaotoIO.
the class ClusterService method getIntegrations.
public List<Integration> getIntegrations() {
List<Integration> res = new ArrayList<>();
try {
final var resources = kubernetesClient.resources(KameletBinding.class).list().getItems();
for (KameletBinding integration : resources) {
Integration i = new Integration();
i.setName(integration.getMetadata().getName());
i.setRunning(true);
i.setResource(integration);
res.add(i);
}
} catch (Exception e) {
log.warn("Error extracting the list of integrations.", e);
}
return res;
}
use of io.kaoto.backend.model.deployment.kamelet.KameletBinding in project kaoto-backend by KaotoIO.
the class KameletBindingDeploymentGeneratorService method parse.
@Override
public String parse(final List<Step> steps, final Map<String, Object> metadata) {
if (!appliesTo(steps)) {
return "";
}
KameletBindingSpec spec = new KameletBindingSpec();
int i = 0;
if (!steps.isEmpty()) {
Step step = steps.get(i);
if ("START".equalsIgnoreCase(step.getType())) {
spec.setSource(createKameletBindingStep(steps.get(i++)));
}
}
for (; i < steps.size() - 1; i++) {
spec.getSteps().add(createKameletBindingStep(steps.get(i)));
}
if (spec.getSteps().isEmpty()) {
spec.setSteps(null);
}
if (steps.size() > 1) {
spec.setSink(createKameletBindingStep(steps.get(steps.size() - 1)));
}
KameletBinding binding = new KameletBinding(String.valueOf(metadata.getOrDefault("name", "")), spec);
Yaml yaml = new Yaml(new Constructor(KameletBinding.class), new KameletRepresenter());
return yaml.dumpAsMap(binding);
}
use of io.kaoto.backend.model.deployment.kamelet.KameletBinding in project kaoto-backend by KaotoIO.
the class KameletBindingStepParserService method deepParse.
@Override
public ParseResult<Step> deepParse(final String input) {
if (!appliesTo(input)) {
throw new IllegalArgumentException("Wrong format provided. This is not parseable by us");
}
ParseResult<Step> res = new ParseResult<>();
List<Step> steps = new ArrayList<>();
try {
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
KameletBinding binding = yamlMapper.readValue(input, KameletBinding.class);
processMetadata(binding.getMetadata());
processSpec(steps, binding.getSpec());
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Wrong format provided. This is not parseable by us");
}
res.setSteps(steps.stream().filter(Objects::nonNull).toList());
return res;
}
Aggregations