This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 18f34ac4573c1870d10df6dacf63e668de74cb4d Author: Pasquale Congiusti <[email protected]> AuthorDate: Mon Jun 7 12:41:39 2021 +0200 doc(example): configmap/secret key selection --- docs/modules/ROOT/pages/cli/modeline.adoc | 4 +-- .../user-config/config-secret-key-route.groovy | 30 ++++++++++++++++++++++ .../resource-configmap-key-location-route.groovy | 27 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/docs/modules/ROOT/pages/cli/modeline.adoc b/docs/modules/ROOT/pages/cli/modeline.adoc index 424a00b..e4daff5 100644 --- a/docs/modules/ROOT/pages/cli/modeline.adoc +++ b/docs/modules/ROOT/pages/cli/modeline.adoc @@ -70,7 +70,7 @@ The following is a partial list of useful options: |Add a build time property or properties file (syntax: _[my-key=my-value\|file:/path/to/my-conf.properties]_ |config -|Add a runtime configuration from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name)_ +|Add a runtime configuration from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key])_ |dependency |An external library that should be included, e.g. for Maven dependencies `dependency=mvn:org.my:app:1.0` @@ -94,7 +94,7 @@ The following is a partial list of useful options: |Add a runtime property or properties file (syntax: _[my-key=my-value\|file:/path/to/my-conf.properties]_) |resource -|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[@path])_ +|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key][@path])_ |trait |Configure a trait, e.g. `trait=service.enabled=false` diff --git a/examples/user-config/config-secret-key-route.groovy b/examples/user-config/config-secret-key-route.groovy new file mode 100644 index 0000000..724a885 --- /dev/null +++ b/examples/user-config/config-secret-key-route.groovy @@ -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-multi --from-literal=my-secret-key="very top secret" --from-literal=my-secret-key-2="even more secret" +// kamel run --config secret:my-sec-multi/my-secret-key-2 config-secret-key-route.groovy --dev +// + +from('timer:secret') + .routeId('secret') + .setBody() + .simple("resource:classpath:my-secret-key-2") + .log('secret content is: ${body}') diff --git a/examples/user-config/resource-configmap-key-location-route.groovy b/examples/user-config/resource-configmap-key-location-route.groovy new file mode 100644 index 0000000..70f39e6 --- /dev/null +++ b/examples/user-config/resource-configmap-key-location-route.groovy @@ -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: +// +// kubectl create configmap my-cm-multi --from-literal=my-configmap-key="configmap content" --from-literal=my-configmap-key-2="another content" +// kamel run --resource configmap:my-cm-multi/my-configmap-key-2@/tmp/app/data resource-configmap-key-location-route.groovy --dev +// + +from('file:/tmp/app/data/?fileName=my-configmap-key-2&noop=true&idempotent=false') + .log('resource file content is: ${body} consumed from ${header.CamelFileName}')
