Skip to content

Commit

Permalink
Migrate to apiVersion v1 from v1aplha1
Browse files Browse the repository at this point in the history
fixes apache#1562

* CRDs move apiVersion from camel.apache.org/v1alpha1 to
camel.apache.org/v1
* Migrate from KameletBinding to Pipe
** Rename kind in CRDs
** Renamed KameletBinding examples by changing suffix -bing 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 Aug 10, 2023
1 parent 5c44e19 commit ae101ec
Show file tree
Hide file tree
Showing 831 changed files with 1,514 additions and 1,514 deletions.
10 changes: 5 additions & 5 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 @@ -59,7 +59,7 @@ All Kamelets present in this repository **MUST** have the *annotation* `camel.ap
We provide an example of Kamelet to give more context to the following sections:

```yaml
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: timer-source
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
### 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 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 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 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
40 changes: 20 additions & 20 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 pipe files in templates/pipes/camel-k
// generator will not generate a pipe example and will source this 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 = shouldGeneratePipeExample(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 = pipes[pipe] || (() => `unrecognized pipe ${pipe}`)
return fn(base, kamelet, platform)
} else {
content = readKameletBindingExample(metadata.name, refApiVersion, refKind, refName)
content = readPipeExample(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 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 shouldGeneratePipeExample(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 pipe example file, assume the example should be generated
return true
}
}

// source the kamelet binding example from the example file
// source the 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 readPipeExample(file, apiVersion, kind, name) {
f = "../camel-kamelets/templates/pipes/camel-k/" + file + ".yaml"
try {
bufContent = fs.readFileSync(f)
content = bufContent.toString()
Expand All @@ -177,19 +177,19 @@ 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 pipe example file " + file + ": " + err)
return err
}
}


const kameletBindings = {
const pipes = {
action: (base, kamelet, platform) => Object.assign(base, {
spec: {
source: {
ref: {
kind: 'Kamelet',
apiVersion: 'camel.apache.org/v1alpha1',
apiVersion: 'camel.apache.org/v1',
name: 'kafka-source',
properties: {
bootstrapServers: 'localhost:9092',
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 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 Pipe in the current namespace on the cluster.

== Kamelet source file

Expand Down
2 changes: 1 addition & 1 deletion kamelets/avro-deserialize-action.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: avro-deserialize-action
Expand Down
2 changes: 1 addition & 1 deletion kamelets/avro-serialize-action.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: avro-serialize-action
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-cloudtrail-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-cloudtrail-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-cloudwatch-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-cloudwatch-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-ddb-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-ddb-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-ddb-streams-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-ddb-streams-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-ec2-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-ec2-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-eventbridge-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-eventbridge-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-kinesis-firehose-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-kinesis-firehose-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-kinesis-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-kinesis-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-kinesis-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-kinesis-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-lambda-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-lambda-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-redshift-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-redshift-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-redshift-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-redshift-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-s3-cdc-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-s3-cdc-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-s3-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-s3-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-s3-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-s3-source
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-s3-streaming-upload-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-s3-streaming-upload-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-secrets-manager-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-secrets-manager-sink
Expand Down
2 changes: 1 addition & 1 deletion kamelets/aws-ses-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: aws-ses-sink
Expand Down
Loading

0 comments on commit ae101ec

Please sign in to comment.