This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit 4f4d55c4989e45d757194411a7db633e9bdce635 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Mon Aug 19 17:28:01 2019 +0200 knative: add custom loader for sources (fix findings) --- .../loader/knative/KnativeSourceRoutesLoader.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/camel-k-loader-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoader.java b/camel-k-loader-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoader.java index 7b106b5..98b1dd7 100644 --- a/camel-k-loader-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoader.java +++ b/camel-k-loader-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoader.java @@ -71,20 +71,20 @@ public class KnativeSourceRoutesLoader implements RoutesLoader { // builder. Maybe, we should add builder lifecycle events. List<RouteDefinition> definitions = builder.configureRoutes(context).getRoutes(); - if (definitions.size() > 1) { - throw new IllegalArgumentException("Cannot determine route top enrich"); + if (definitions.size() == 1) { + final String sink = context.resolvePropertyPlaceholders("{{env:KNATIVE_SINK:sink}}"); + final String uri = String.format("knative://endpoint/%s", sink); + final RouteDefinition definition = definitions.get(0); + + LOGGER.info("Add sink:{} to route:{}", uri, definition.getId()); + + // assuming that route is linear like there's no content based routing + // or ant other EIP that would branch the flow + definition.getOutputs().add(new ToDefinition(uri)); + } else { + LOGGER.warn("Cannot determine route to enrich. the knative enpoint need to explicitly be defined"); } - final String sink = context.resolvePropertyPlaceholders("{{env:KNATIVE_SYNC:sink}}"); - final String uri = String.format("knative://endpoint/%s", sink); - final RouteDefinition definition = definitions.get(0); - - LOGGER.info("Add sink:{} to route:{}", uri, definition.getId()); - - // assuming that route is linear like there's no content based routing - // or ant other EIP that would branch the flow - definition.getOutputs().add(new ToDefinition(uri)); - //TODO: this is needed for java language because by default // camel main inspects route builders to detect beans // to be registered to the camel registry but as the