From 77f42274bde095c4ec519f2d2cbfdefd2b536d7b Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Wed, 20 May 2020 18:45:29 +0200 Subject: [PATCH] examples: improve knative example --- .../camel/component/knative/knative.json | 2 +- .../data/env.json | 2 +- .../data/routes.yaml | 38 +++++++++++++------ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json index ea549c768..0a5403963 100644 --- a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json +++ b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json @@ -30,7 +30,7 @@ "type": { "kind": "path", "displayName": "Type", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.knative.spi.Knative.Type", "enum": [ "endpoint", "channel", "event" ], "deprecated": false, "secret": false, "description": "The Knative type" }, "name": { "kind": "path", "displayName": "Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The Knative name" }, "ceOverride": { "kind": "parameter", "displayName": "Ce Override", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.util.Map", "prefix": "ce.override.", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "CloudEvent headers to override" }, - "cloudEventsSpecVersion": { "kind": "parameter", "displayName": "Cloud Events Spec Version", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "0.1", "0.2", "0.3", "1.0" ], "deprecated": false, "secret": false, "defaultValue": "0.1", "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "Set the version of the cloudevents spec." }, + "cloudEventsSpecVersion": { "kind": "parameter", "displayName": "Cloud Events Spec Version", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "0.1", "0.2", "0.3", "1.0" ], "deprecated": false, "secret": false, "defaultValue": "1.0", "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "Set the version of the cloudevents spec." }, "cloudEventsType": { "kind": "parameter", "displayName": "Cloud Events Type", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "defaultValue": "org.apache.camel.event", "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "Set the event-type information of the produced events." }, "environment": { "kind": "parameter", "displayName": "Environment", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.knative.spi.KnativeEnvironment", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "The environment" }, "filters": { "kind": "parameter", "displayName": "Filters", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.util.Map", "prefix": "filter.", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.knative.KnativeConfiguration", "configurationField": "configuration", "description": "Set the filters." }, diff --git a/examples/camel-k-runtime-example-knative/data/env.json b/examples/camel-k-runtime-example-knative/data/env.json index 204a3e08f..e9cd1f640 100644 --- a/examples/camel-k-runtime-example-knative/data/env.json +++ b/examples/camel-k-runtime-example-knative/data/env.json @@ -1,7 +1,7 @@ { "services": [{ "type": "endpoint", - "name": "from", + "name": "echoer", "metadata": { "camel.endpoint.kind": "source" } diff --git a/examples/camel-k-runtime-example-knative/data/routes.yaml b/examples/camel-k-runtime-example-knative/data/routes.yaml index dae43ba93..3bfe20dac 100644 --- a/examples/camel-k-runtime-example-knative/data/routes.yaml +++ b/examples/camel-k-runtime-example-knative/data/routes.yaml @@ -15,15 +15,29 @@ # limitations under the License. # -- route: - id: "knative" - group: "routes" - from: - uri: "knative:endpoint/from" - steps: - - convert-body-to: - type: "java.lang.String" - - to: - uri: "log:knative" - - set-body: - constant: "Hello from camel-k (native)" \ No newline at end of file +- from: + uri: "knative:endpoint/echoer" + steps: + - log: + message: "Got Message: ${body}" + - convert-body-to: "java.lang.String" + - choice: + when: + - simple: "${body} != null && ${body.length} > 0" + steps: + - set-body: + simple: "${body.toUpperCase()}" + - set-header: + name: ContentType + simple: text/plain + - log: + message: "${body}" + otherwise: + steps: + - set-body: + constant: "no body received" + - set-header: + name: ContentType + simple: text/plain + - log: + message: "Otherwise::${body}" \ No newline at end of file