Skip to content

Commit

Permalink
chore(example): complete set of user config
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed May 14, 2021
1 parent 2b4ab30 commit d76d251
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 32 deletions.
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ In this section you will find the most basic examples. Useful to start learning
| Type | Description | Link |
|---|---|---|
| Languages | Simple integrations developed in various supported languages | [see examples](./languages/)|
| Basic | Basic features such as `cron`, `properties` or `resource`s | [see examples](./basic/)|
| Cron | How to create a `cront` integration | [see examples](./cron/)|
| User Config | Explore how to include a `property`, `secret`, `configmap` or file `resource` in your integration | [see examples](./user-config/)|
| Processor | Show how to include `Processor`s logic | [see examples](./processor/)|
| Open API | `Open API` support | [see examples](./openapi/)|
| Rest | Produce/Consume `REST`ful services | [see examples](./rest/)|
Expand Down
3 changes: 0 additions & 3 deletions examples/basic/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions examples/basic/props.js

This file was deleted.

3 changes: 3 additions & 0 deletions examples/cron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Camel K cron examples

Find useful examples about how to create a cron route in Camel K.
File renamed without changes.
6 changes: 6 additions & 0 deletions examples/kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This example shows how Camel K can be used to connect to a Kafka broker.

## Authentication to Kafka

We have a dedicated section to show [how to authenticate Camel K to Kafka](./sasl_ssl/).

## Simple usage

To run this example first set-up Kafka on your k8s cluster.
A convenient way to do so is by using the Strimzi project, if you are using minikube follow these instructions at https://strimzi.io/quickstarts/minikube/

Expand Down
3 changes: 3 additions & 0 deletions examples/user-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Camel K user configuration examples

Find useful examples about how to include a configuration property or a configuration file in Camel K.
30 changes: 30 additions & 0 deletions examples/user-config/configmap-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
//
// kubectl create configmap my-cm --from-literal=my-configmap-key="configmap content"
// kamel run --configmap my-cm configmap-route.groovy --dev
//

from('timer:configmap')
.routeId('configmap')
.setBody()
.simple("resource:classpath:my-configmap-key")
.log('configmap content is: ${body}')
2 changes: 2 additions & 0 deletions examples/user-config/my.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my.key.1=hello
my.key.2=world
27 changes: 27 additions & 0 deletions examples/user-config/property-file-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
//
// kamel run --property-file my.properties property-file-route.groovy --dev
//

from('timer:property-file')
.routeId('property-file')
.log('property file content is: {{my.key.1}} {{my.key.2}}')
27 changes: 27 additions & 0 deletions examples/user-config/property-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
//
// kamel run -p my.message=test-property property-route.groovy --dev
//

from('timer:property')
.routeId('property')
.log('property content is: {{my.message}}')
28 changes: 28 additions & 0 deletions examples/user-config/resources-base64-encoded-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
// kamel run --resource resources-data.txt --compression=true resources-base64-encoded-route.groovy --dev
//

from('timer:resources-bas64')
.routeId('resources-base64')
.setBody()
.simple("resource:classpath:resources-data.txt")
.log('resource file base64 content is: ${body}')
27 changes: 27 additions & 0 deletions examples/user-config/resources-binary-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
// kamel run --resource resources-data.zip resources-binary-route.groovy -d camel-zipfile --dev
//

from('file:/etc/camel/resources/?fileName=resources-data.zip&noop=true&idempotent=false')
.routeId('resources-zip')
.unmarshal().zipFile()
.log('resource file unzipped content is: ${body}')
File renamed without changes.
Binary file added examples/user-config/resources-data.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

//
// To run this integrations use:
//
// kamel run --resource examples/resources-data.txt examples/resources-route.groovy
// kamel run --resource resources-data.txt resources-route.groovy --dev
//

from('timer:resources')
.routeId('resources')
.setBody()
.simple("resource:classpath:resources-data.txt")
.log('file content is: ${body}')
.log('resource file content is: ${body}')
30 changes: 30 additions & 0 deletions examples/user-config/secret-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//
// To run this integrations use:
//
// kubectl create secret generic my-sec --from-literal=my-secret-key="very top secret"
// kamel run --secret my-sec secret-route.groovy --dev
//

from('timer:secret')
.routeId('secret')
.setBody()
.simple("resource:classpath:my-secret-key")
.log('secret content is: ${body}')

0 comments on commit d76d251

Please sign in to comment.