Skip to content

Commit

Permalink
Migrate from KameletBinding to Pipe
Browse files Browse the repository at this point in the history
fixes #1562

* Renamed kind in CRDs
* Renamed KameletBinding examples by changing suffix -binding to -pipe
* Renamed folder and file names having binding
* Updated doc
* Updated Yaks tests

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Sep 25, 2023
1 parent b8da078 commit f15f942
Show file tree
Hide file tree
Showing 422 changed files with 746 additions and 747 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains the default Kamelet catalog used by Apache Camel and its sub-projects.

Kamelets in this repository can be used natively in Camel K, Camel, Camel-Quarkus and Camel-spring-boot integrations, without additional configuration steps. Users just need to reference the Kamelets by name in the URI (e.g. `kamelet:timer-source?message=Hello`), or use them in a `KameletBinding`, for Camel K, in particular.
Kamelets in this repository can be used natively in Camel K, Camel, Camel-Quarkus and Camel-spring-boot integrations, without additional configuration steps. Users just need to reference the Kamelets by name in the URI (e.g. `kamelet:timer-source?message=Hello`), or use them in a `Pipe`, for Camel K, in particular.

**NOTE**: Camel K (and other sub-projects) will only use a specific version of this Kamelet catalog. Refer to the release notes of the sub-project for more information.

Expand Down Expand Up @@ -162,11 +162,11 @@ Kamelets submitted with tests that verify their correctness **MUST** be labeled

**NOTE**: there's no way at the moment to inject credentials for external systems into the CI in order to write more advanced tests, but we can expect we'll find an usable strategy in the long run

### Kamelet Binding Examples
### Kamelet Pipe Examples

Binding examples are highly encouraged to be added under `templates/bindings/camel-k` directory for Kamelet Binding and `templates/bindings/core` for the YAML routes.
Pipe examples are highly encouraged to be added under `templates/pipes/camel-k` directory for Kamelet Pipe and `templates/pipes/core` for the YAML routes.

When the Kamelet Catalog documentation is generated, the examples in each Kamelet documentation page are automatically generated, but the generator code is not wise enough and it may generate a Kamelet Binding that doesn't work, requiring additional steps. In this case, the binding example should be added to the above mentioned directories, and add the comment marker at the first line `"# example_for_kamelet_doc"` only in the Camel K Kamelet Binding example (in `templates/bindings/camel-k`). When the documentation mechanism runs, it will source this binding example into the kamelet documentation page as example.
When the Kamelet Catalog documentation is generated, the examples in each Kamelet documentation page are automatically generated, but the generator code is not wise enough and it may generate a Kamelet Pipe that doesn't work, requiring additional steps. In this case, the pipe example should be added to the above mentioned directories, and add the comment marker at the first line `"# example_for_kamelet_doc"` only in the Camel K Kamelet Pipe example (in `templates/pipes/camel-k`). When the documentation mechanism runs, it will source this pipe example into the kamelet documentation page as example.

## Releasing

Expand Down
38 changes: 19 additions & 19 deletions docs/modules/ROOT/examples/js/kamelets.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const QUOTE_REPLACEMENTS = {
'\\': '\\\\',
}

// marker added to the first line of kamelet binding files in templates/bindings/camel-k
// generator will not generate a kamelet binding example and will source this kamelet binding file into the generated doc
// marker added to the first line of kamelet pipe files in templates/pipes/camel-k
// generator will not generate a kamelet pipe example and will source this kamelet pipe file into the generated doc
const EXAMPLE_KAMELET_DOC_MARKER = "example_for_kamelet_doc"

// regex to replace the sink type
Expand All @@ -38,11 +38,11 @@ const regex = new RegExp(`( sink:\\n\\s*ref:\\n)(\\s*kind:)(.*)(\\n\\s*apiVersi
const svgb64Prefix = 'data:image/svg+xml;base64,'

module.exports = {
binding: (binding, apiVersion, kind, metadata_, spec_, refKind, refApiVersion, refName) => {
pipe: (pipe, apiVersion, kind, metadata_, spec_, refKind, refApiVersion, refName) => {
const name = metadata_.name
const metadata = {name: `${name}-binding`}
const metadata = {name: `${name}-pipe`}

genExample = shouldGenerateKameletBindingExample(metadata.name)
genExample = shouldGenerateKameletPipeExample(metadata.name)
if (genExample) {
const kamelet = {
ref: {
Expand All @@ -61,19 +61,19 @@ module.exports = {
}
const base = {
apiVersion,
kind: 'KameletBinding',
kind: 'Pipe',
metadata,
}
const fn = kameletBindings[binding] || (() => `unrecognized binding ${binding}`)
const fn = kameletPipes[pipe] || (() => `unrecognized pipe ${pipe}`)
return fn(base, kamelet, platform)
} else {
content = readKameletBindingExample(metadata.name, refApiVersion, refKind, refName)
content = readKameletPipeExample(metadata.name, refApiVersion, refKind, refName)
return content
}
},

bindingCommand: (binding, name, definition, topic) => {
const namePrefix = { action: 'step-0', sink: 'sink', source: 'source' }[binding]
pipeCommand: (pipe, name, definition, topic) => {
const namePrefix = { action: 'step-0', sink: 'sink', source: 'source' }[pipe]
const quote = (string) => (typeof string === 'String')
? string.replace(QUOTED_CHARS, (m) => QUOTE_REPLACEMENTS[m])
: string
Expand Down Expand Up @@ -144,25 +144,25 @@ function kameletPropertyList (definition) {
)
}

// verify if the existing kamelet binding example should be automatically generated
// verify if the existing kamelet pipe example should be automatically generated
// by checking if there is a comment marker in the first line
function shouldGenerateKameletBindingExample(file) {
f = "../camel-kamelets/templates/bindings/camel-k/" + file + ".yaml"
function shouldGenerateKameletPipeExample(file) {
f = "../camel-kamelets/templates/pipes/camel-k/" + file + ".yaml"
try {
bufContent = fs.readFileSync(f)
content = bufContent.toString()
line = content.split(/\r?\n/)[0]
return line.indexOf(EXAMPLE_KAMELET_DOC_MARKER) < 0
} catch (err) {
// in case there is no kamelet binding example file, assume the example should be generated
// in case there is no kamelet pipe example file, assume the example should be generated
return true
}
}

// source the kamelet binding example from the example file
// source the kamelet pipe example from the example file
// skip the first line and replace the sink kind when the kind is a knative channel
function readKameletBindingExample(file, apiVersion, kind, name) {
f = "../camel-kamelets/templates/bindings/camel-k/" + file + ".yaml"
function readKameletPipeExample(file, apiVersion, kind, name) {
f = "../camel-kamelets/templates/pipes/camel-k/" + file + ".yaml"
try {
bufContent = fs.readFileSync(f)
content = bufContent.toString()
Expand All @@ -177,13 +177,13 @@ function readKameletBindingExample(file, apiVersion, kind, name) {
yamlDoc = yaml.load(klbContent);
return yamlDoc
} catch (err) {
console.log("Error reading kamelet binding example file " + file + ": " + err)
console.log("Error reading kamelet pipe example file " + file + ": " + err)
return err
}
}


const kameletBindings = {
const kameletPipes = {
action: (base, kamelet, platform) => Object.assign(base, {
spec: {
source: {
Expand Down
24 changes: 12 additions & 12 deletions docs/modules/ROOT/examples/template/kamelet-options.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ endif::[]
:ref-kind: Channel
:ref-name: mychannel

.{name}-binding.yaml
.{name}-pipe.yaml
[source,yaml,subs='+attributes,macros']
----
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$', format='kamelets.binding("{type}", apiVersion, kind, metadata, spec, "{ref-kind}", "{ref-api-version}", "{ref-name}")', outputFormat=yml, requires={requires}]
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$', format='kamelets.pipe("{type}", apiVersion, kind, metadata, spec, "{ref-kind}", "{ref-api-version}", "{ref-name}")', outputFormat=yml, requires={requires}]
----

==== *Prerequisite*
Expand All @@ -93,13 +93,13 @@ You have xref:{camel-k-docs-version}@camel-k::installation/installation.adoc[Cam

==== *Procedure for using the cluster CLI*

. Save the \`{name}-binding.yaml\` file to your local drive, and then edit it as needed for your configuration.
. Save the \`{name}-pipe.yaml\` file to your local drive, and then edit it as needed for your configuration.

. Run the {type} by using the following command:
+
[source,shell,subs=+attributes]
----
kubectl apply -f {name}-binding.yaml
kubectl apply -f {name}-pipe.yaml
----

==== *Procedure for using the Kamel CLI*
Expand All @@ -108,10 +108,10 @@ Configure and run the {type} by using the following command:

[source,shell,subs='+attributes,macros']
----
jsonpathExpression:example$yaml/${basename}.kamelet.yaml[query='$.spec', format='kamelets.bindingCommand("{type}", "{name}", definition, "channel:mychannel")', requires={requires}]
jsonpathExpression:example$yaml/${basename}.kamelet.yaml[query='$.spec', format='kamelets.pipeCommand("{type}", "{name}", definition, "channel:mychannel")', requires={requires}]
----

This command creates the KameletBinding in the current namespace on the cluster.
This command creates the Kamelet Pipe in the current namespace on the cluster.

=== Kafka {type}

Expand All @@ -126,10 +126,10 @@ endif::[]
:ref-kind: KafkaTopic
:ref-name: my-topic

.{name}-binding.yaml
.{name}-pipe.yaml
[source,yaml,subs='+attributes,macros']
----
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$', format='kamelets.binding("{type}", apiVersion, kind, metadata, spec, "{ref-kind}", "{ref-api-version}", "{ref-name}")', outputFormat=yml, requires={requires}]
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$', format='kamelets.pipe("{type}", apiVersion, kind, metadata, spec, "{ref-kind}", "{ref-api-version}", "{ref-name}")', outputFormat=yml, requires={requires}]
----

==== *Prerequisites*
Expand All @@ -140,13 +140,13 @@ jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$', format='kam

==== *Procedure for using the cluster CLI*

. Save the \`{name}-binding.yaml\` file to your local drive, and then edit it as needed for your configuration.
. Save the \`{name}-pipe.yaml\` file to your local drive, and then edit it as needed for your configuration.

. Run the {type} by using the following command:
+
[source,shell,subs=+attributes]
----
kubectl apply -f {name}-binding.yaml
kubectl apply -f {name}-pipe.yaml
----

==== *Procedure for using the Kamel CLI*
Expand All @@ -155,10 +155,10 @@ Configure and run the {type} by using the following command:

[source,shell,subs='+attributes,macros']
----
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$.spec', format='kamelets.bindingCommand("{type}", "{name}", definition, "kafka.strimzi.io/v1beta1:KafkaTopic:my-topic")', requires={requires}]
jsonpathExpression::example$yaml/${basename}.kamelet.yaml[query='$.spec', format='kamelets.pipeCommand("{type}", "{name}", definition, "kafka.strimzi.io/v1beta1:KafkaTopic:my-topic")', requires={requires}]
----

This command creates the KameletBinding in the current namespace on the cluster.
This command creates the Kamelet Pipe in the current namespace on the cluster.

== Kamelet source file

Expand Down
2 changes: 1 addition & 1 deletion kamelets/jms-ibm-mq-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
description: |-
A Kamelet that can produce events to an IBM MQ message queue using JMS.
In your KameletBinding file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
- "mvn:com.ibm.mq:com.ibm.mq.allclient:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/jms-ibm-mq-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
description: |-
A Kamelet that can read events from an IBM MQ message queue using JMS.
In your KameletBinding file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
- "mvn:com.ibm.mq:com.ibm.mq.allclient:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/mariadb-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a MariaDB Database.
In your KameletBinding file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies.
- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/mariadb-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a MariaDB Database.
In your KameletBinding file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"
required:
Expand Down
2 changes: 1 addition & 1 deletion kamelets/mysql-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a MySQL Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
- "mvn:mysql:mysql-connector-java:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/mysql-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a MySQL Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
- "mvn:mysql:mysql-connector-java:<version>"
required:
Expand Down
2 changes: 1 addition & 1 deletion kamelets/oracle-database-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to an Oracle Database.
In your KameletBinding file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
- "mvn:com.oracle.database.jdbc:ojdbc11:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/oracle-database-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from an Oracle Database.
In your KameletBinding file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
- "mvn:com.oracle.database.jdbc:ojdbc11:<version>"
required:
Expand Down
2 changes: 1 addition & 1 deletion kamelets/sqlserver-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a Microsoft SQL Server Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"
Expand Down
2 changes: 1 addition & 1 deletion kamelets/sqlserver-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a Microsoft SQL Server Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
description: |-
A Kamelet that can produce events to an IBM MQ message queue using JMS.
In your KameletBinding file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
- "mvn:com.ibm.mq:com.ibm.mq.allclient:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
description: |-
A Kamelet that can read events from an IBM MQ message queue using JMS.
In your KameletBinding file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the IBM MQ Server driver dependency in spec->integration->dependencies
- "mvn:com.ibm.mq:com.ibm.mq.allclient:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a MariaDB Database.
In your KameletBinding file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies.
- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a MariaDB Database.
In your KameletBinding file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a MySQL Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
- "mvn:mysql:mysql-connector-java:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a MySQL Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies.
- "mvn:mysql:mysql-connector-java:<version>"
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to an Oracle Database.
In your KameletBinding file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
- "mvn:com.oracle.database.jdbc:ojdbc11:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from an Oracle Database.
In your KameletBinding file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
In your Pipe file, you must explicitly declare the Oracle Database driver dependency in spec->integration->dependencies.
- "mvn:com.oracle.database.jdbc:ojdbc11:<version>"
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Send data to a Microsoft SQL Server Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
description: |-
Query data from a Microsoft SQL Server Database.
In your KameletBinding file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your Pipe file, you must explicitly declare the SQL Server driver dependency in spec->integration->dependencies
- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"
required:
Expand Down
1 change: 0 additions & 1 deletion templates/bindings/camel-k/kamelet.yaml.tmpl

This file was deleted.

Loading

0 comments on commit f15f942

Please sign in to comment.