Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mail sink Kamelet #610

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ concurrency:

env:
CAMEL_K_VERSION: 1.5.0
YAKS_VERSION: 0.4.0
YAKS_VERSION: 0.6.0
YAKS_IMAGE_NAME: "docker.io/citrusframework/yaks"

jobs:
test:
Expand All @@ -62,7 +63,7 @@ jobs:
rm -r _kamel
- name: Get YAKS CLI
run: |
curl --fail -L --silent https://github.com/citrusframework/yaks/releases/download/v${YAKS_VERSION}/yaks-${YAKS_VERSION}-linux-64bit.tar.gz -o yaks.tar.gz
curl --fail -L --silent https://github.com/citrusframework/yaks/releases/download/${YAKS_VERSION}/yaks-${YAKS_VERSION}-linux-64bit.tar.gz -o yaks.tar.gz
mkdir -p _yaks
tar -zxf yaks.tar.gz --directory ./_yaks
sudo mv ./_yaks/yaks /usr/local/bin/
Expand All @@ -85,10 +86,10 @@ jobs:
export KAMEL_INSTALL_REGISTRY_INSECURE=true

echo "Configuring Yaks"
yaks install
yaks install --operator-image $YAKS_IMAGE_NAME:$YAKS_VERSION

echo "Running tests"
yaks test ./test
yaks run ./test
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ components/camel-cxf/activemq-data
.flattened-pom.xml
.java-version
node_modules/

_output
68 changes: 68 additions & 0 deletions docs/modules/ROOT/assets/images/kamelets/mail-sink.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
* xref:ROOT:kubernetes-pods-source.adoc[image:kamelets/kubernetes-pods-source.svg[] Kubernetes Pods Source]
* xref:ROOT:log-sink.adoc[image:kamelets/log-sink.svg[] Log Sink]
* xref:ROOT:mail-imap-source.adoc[image:kamelets/mail-imap-source.svg[] Mail IMAP Source]
* xref:ROOT:mail-sink.adoc[image:kamelets/mail-sink.svg[] Mail Sink]
* xref:ROOT:mariadb-sink.adoc[image:kamelets/mariadb-sink.svg[] MariaDB Sink]
* xref:ROOT:mariadb-source.adoc[image:kamelets/mariadb-source.svg[] MariaDB Source]
* xref:ROOT:mask-field-action.adoc[image:kamelets/mask-field-action.svg[] Mask Fields Action]
Expand Down
158 changes: 158 additions & 0 deletions docs/modules/ROOT/pages/mail-sink.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT

= image:kamelets/mail-sink.svg[] Mail Sink

*Provided by: "Apache Software Foundation"*

*Support Level for this Kamelet is: "Preview"*

Send mails to given SMTP server.

== Configuration Options

The following table summarizes the configuration options available for the `mail-sink` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *connectionHost {empty}* *| Host| The mail server host| string| | `"smtp.gmail.com"`
| *password {empty}* *| Password| The password to access the mail box| string| |
| *username {empty}* *| Username| The username to access the mail box| string| |
| connectionPort| Port| The mail server port| string| `25`|
| from| From| The `from` field of the outgoing mail| string| |
| protocol| Protocol| The mail protocol to use| string| `"smtp"`|
| subject| Subject| The mail subject of the outgoing mail| string| |
| to| To| The `to` field of the outgoing mail| string| |
|===

NOTE: Fields marked with an asterisk ({empty}*) are mandatory.


== Dependencies

At runtime, the `mail-sink` Kamelet relies upon the presence of the following dependencies:

- camel:core
- camel:mail
- camel:kamelet

== Usage

This section describes how you can use the `mail-sink`.

=== Knative Sink

You can use the `mail-sink` Kamelet as a Knative sink by binding it to a Knative object.

.mail-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: mail-sink-binding
spec:
source:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: mail-sink
properties:
connectionHost: "smtp.gmail.com"
password: "The Password"
username: "The Username"

----

==== *Prerequisite*

You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

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

. Save the `mail-sink-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the sink by using the following command:
+
[source,shell]
----
kubectl apply -f mail-sink-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the sink by using the following command:

[source,shell]
----
kamel bind channel:mychannel mail-sink -p "sink.connectionHost=smtp.gmail.com" -p "sink.password=The Password" -p "sink.username=The Username"
----

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

=== Kafka Sink

You can use the `mail-sink` Kamelet as a Kafka sink by binding it to a Kafka topic.

.mail-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: mail-sink-binding
spec:
source:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: mail-sink
properties:
connectionHost: "smtp.gmail.com"
password: "The Password"
username: "The Username"

----

==== *Prerequisites*

* You've installed https://strimzi.io/[Strimzi].
* You've created a topic named `my-topic` in the current namespace.
* You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

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

. Save the `mail-sink-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the sink by using the following command:
+
[source,shell]
----
kubectl apply -f mail-sink-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the sink by using the following command:

[source,shell]
----
kamel bind kafka.strimzi.io/v1beta1:KafkaTopic:my-topic mail-sink -p "sink.connectionHost=smtp.gmail.com" -p "sink.password=The Password" -p "sink.username=The Username"
----

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

== Kamelet source file

https://github.com/apache/camel-kamelets/blob/main/kamelets/mail-sink.kamelet.yaml

// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
118 changes: 118 additions & 0 deletions kamelets/mail-sink.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: mail-sink
annotations:
camel.apache.org/kamelet.support.level: "Preview"
camel.apache.org/catalog.version: "main-SNAPSHOT"
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOn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MC4xIHYgMTIgaCAxNiB2IC0xMiB6IG0gMS40MTQwNjI1LDEgSCAxNC42ODU5MzggTCA4LjEsNy42ODU5Mzc1IFogTSAxLjEsMi4xIGwgNCw0IC00LDQgeiBtIDE0LDAgdiA4IGwgLTQsLTQgeiBNIDUuODA3MDMxMiw2LjgwNzAzMTIgOC4xLDkuMSAxMC4zOTI5NjksNi44MDcwMzEyIDE0LjY4NTkzOCwxMS4xIEggMS41MTQwNjI1IFoiCiAgICAgaWQ9InJlY3Q0MTQ0IgogICAgIGNsYXNzPSJDb2xvclNjaGVtZS1UZXh0IiAvPgo8L3N2Zz4K"
camel.apache.org/provider: "Apache Software Foundation"
camel.apache.org/kamelet.group: "Mail"
labels:
camel.apache.org/kamelet.type: "sink"
spec:
definition:
title: "Mail Sink"
description: "Send mails to given SMTP server."
required:
- connectionHost
- username
- password
type: object
properties:
protocol:
description: The mail protocol to use
default: smtp
title: Protocol
type: string
connectionHost:
description: The mail server host
example: smtp.gmail.com
title: Host
type: string
connectionPort:
description: The mail server port
title: Port
default: 25
type: string
username:
title: Username
description: The username to access the mail box
type: string
x-descriptors:
- urn:camel:group:credentials
password:
title: Password
description: The password to access the mail box
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
- urn:camel:group:credentials
from:
description: The `from` field of the outgoing mail
title: From
type: string
to:
description: The `to` field of the outgoing mail
title: To
type: string
subject:
description: The mail subject of the outgoing mail
title: Subject
type: string
dependencies:
- "camel:core"
- "camel:mail"
- "camel:kamelet"
flow:
from:
uri: "kamelet:source"
steps:
- choice:
when:
- simple: "${header[ce-subject]}"
steps:
- set-header:
name: Subject
simple: "${header[ce-subject]}"
- choice:
when:
- simple: "${header[ce-from]}"
steps:
- set-header:
name: From
simple: "${header[ce-from]}"
- choice:
when:
- simple: "${header[ce-to]}"
steps:
- set-header:
name: To
simple: "${header[ce-to]}"
- choice:
when:
- simple: "${header[ce-cc]}"
steps:
- set-header:
name: Cc
simple: "${header[ce-cc]}"
- remove-headers:
pattern: "ce-*"
- to: '{{protocol}}://{{connectionHost}}:{{connectionPort}}?subject={{subject}}&from={{from}}&to={{to}}&username={{username}}&password={{password}}'