This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new 24ece7a3f chore: default data types on the MinIO and SSH sources 
(#3117) (#3302)
24ece7a3f is described below

commit 24ece7a3f1c0ddf78c84ff6479a2ed8363b2eeef
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 20 21:23:41 2026 +0100

    chore: default data types on the MinIO and SSH sources (#3117) (#3302)
    
    minio-source gives the file as bytes (application-octet-stream) and
    ssh-source the command output as text (text-plain); both bodies were
    already of that kind, so the default only sets Content-Type. The Output:
    paragraphs say so and the Citrus tests expect the header.
    
    ftp-source, ftps-source, sftp-source and ceph-source keep no default:
    with streamDownload=true (includeBody=false for ceph) and stream caching
    off, application-octet-stream would read the whole file into a byte[]
    where today the download stream is handed on. A new Citrus test records
    that sftp-source with streamDownload=true gives a stream.
    
    
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 kamelets/minio-source.kamelet.yaml                 |  8 ++++-
 kamelets/ssh-source.kamelet.yaml                   |  8 ++++-
 .../main/resources/META-INF/kamelets-index.json    |  4 +--
 .../resources/kamelets/minio-source.kamelet.yaml   |  8 ++++-
 .../resources/kamelets/ssh-source.kamelet.yaml     |  8 ++++-
 .../minio/minio-source-route.citrus.it.yaml        |  2 +-
 .../test/resources/minio/minio-source-route.yaml   |  3 ++
 ...aml => sftp-source-stream-route.citrus.it.yaml} | 27 +++++++++--------
 .../sftp-source-stream-route.yaml}                 | 35 ++++++++++------------
 .../resources/ssh/ssh-source-route.citrus.it.yaml  |  2 +-
 10 files changed, 66 insertions(+), 39 deletions(-)

diff --git a/kamelets/minio-source.kamelet.yaml 
b/kamelets/minio-source.kamelet.yaml
index 95cdf5207..014ee7413 100644
--- a/kamelets/minio-source.kamelet.yaml
+++ b/kamelets/minio-source.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
 
       Use it to process files that another system drops into a MinIO bucket, 
such as uploaded documents, exported reports or log files. For Amazon S3 use 
`aws-s3-source`, and for the S3 gateway of Ceph use `ceph-source`.
 
-      Output: the body is the content of the file, as bytes. The headers give 
the bucket name, the name of the file (`CamelMinioObjectName`), and its content 
type, size, ETag and last modified date.
+      Output: the body is the content of the file, as bytes, and the 
`Content-Type` header is set to `application/octet-stream`. The headers give 
the bucket name, the name of the file (`CamelMinioObjectName`), and the content 
type the file was stored with (`CamelMinioContentType`), its size, ETag and 
last modified date.
 
       Good to know: files are deleted from the bucket after they are read, 
unless `deleteAfterRead` is set to false; then the same files are read again on 
every poll, about twice a second. Only the files at the top of the bucket are 
read: a file in a folder, such as `reports/january.csv`, is not.
     required:
@@ -82,6 +82,7 @@ spec:
         default: false
   dataTypes:
     out:
+      default: binary
       headers:
         CamelMinioBucketName:
           title: Bucket Name
@@ -103,6 +104,11 @@ spec:
           title: ETag
           description: The ETag of the file, which changes when its content 
changes.
           type: string
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The content of the file, as bytes."
+          mediaType: application/octet-stream
   dependencies:
   - "camel:minio"
   - "camel:kamelet"
diff --git a/kamelets/ssh-source.kamelet.yaml b/kamelets/ssh-source.kamelet.yaml
index ccf1db038..e6407c82d 100644
--- a/kamelets/ssh-source.kamelet.yaml
+++ b/kamelets/ssh-source.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
 
       Use it to watch a server without installing anything on it, for example 
check the free disk space, the state of a service or the last lines of a log 
file every minute. To run a command for each incoming message instead, use 
`ssh-sink`.
 
-      Output: the body is what the command printed on its standard output, as 
text. The `CamelSshExitValue` header holds the exit code of the command, and 
`CamelSshStderr` what it printed on its standard error, as a stream.
+      Output: the body is what the command printed on its standard output, as 
text, and the `Content-Type` header is set to `text/plain`. The 
`CamelSshExitValue` header holds the exit code of the command, and 
`CamelSshStderr` what it printed on its standard error, as a stream.
 
       Good to know: it runs `pollCommand` with the rights of `username`, so 
log in with an account that may do only what is needed. It runs it every half 
second by default; set `delay` to how often you need it. A command that fails 
still sends a message, with its exit code in `CamelSshExitValue`. Log in with 
`password`, or with a private key in `privateKeyResource` when the server does 
not take passwords; when a key is set, the password is not used. The key of the 
server is checked only  [...]
     required:
@@ -110,6 +110,7 @@ spec:
         example: df -h /
   dataTypes:
     out:
+      default: text
       headers:
         CamelSshExitValue:
           title: Exit Code
@@ -119,6 +120,11 @@ spec:
           title: Standard Error
           description: What the command printed on its standard error, as a 
stream.
           type: object
+      types:
+        text:
+          format: "text-plain"
+          description: "What the command printed on its standard output, as 
text."
+          mediaType: text/plain
   dependencies:
     - "camel:ssh"
     - "camel:kamelet"
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 33c209bbb..230df704b 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -1465,7 +1465,7 @@
     "supportLevel" : "Stable",
     "title" : "Minio Source",
     "summary" : "Reads the files (objects) in a MinIO bucket, one message per 
file, and by default deletes each file once it has been read.",
-    "description" : "Reads the files (objects) in a MinIO bucket, one message 
per file, and by default deletes each file once it has been read.\n\nUse it to 
process files that another system drops into a MinIO bucket, such as uploaded 
documents, exported reports or log files. For Amazon S3 use `aws-s3-source`, 
and for the S3 gateway of Ceph use `ceph-source`.\n\nOutput: the body is the 
content of the file, as bytes. The headers give the bucket name, the name of 
the file (`CamelMinioObjec [...]
+    "description" : "Reads the files (objects) in a MinIO bucket, one message 
per file, and by default deletes each file once it has been read.\n\nUse it to 
process files that another system drops into a MinIO bucket, such as uploaded 
documents, exported reports or log files. For Amazon S3 use `aws-s3-source`, 
and for the S3 gateway of Ceph use `ceph-source`.\n\nOutput: the body is the 
content of the file, as bytes, and the `Content-Type` header is set to 
`application/octet-stream`. The  [...]
     "group" : "Minio",
     "namespace" : "Cloud",
     "provider" : "Apache Software Foundation"
@@ -2075,7 +2075,7 @@
     "supportLevel" : "Stable",
     "title" : "SSH Source",
     "summary" : "Runs a command on a remote server over SSH again and again, 
at a regular interval, and sends what the command prints as a message each 
time.",
-    "description" : "Runs a command on a remote server over SSH again and 
again, at a regular interval, and sends what the command prints as a message 
each time.\n\nUse it to watch a server without installing anything on it, for 
example check the free disk space, the state of a service or the last lines of 
a log file every minute. To run a command for each incoming message instead, 
use `ssh-sink`.\n\nOutput: the body is what the command printed on its standard 
output, as text. The `Camel [...]
+    "description" : "Runs a command on a remote server over SSH again and 
again, at a regular interval, and sends what the command prints as a message 
each time.\n\nUse it to watch a server without installing anything on it, for 
example check the free disk space, the state of a service or the last lines of 
a log file every minute. To run a command for each incoming message instead, 
use `ssh-sink`.\n\nOutput: the body is what the command printed on its standard 
output, as text, and the `C [...]
     "group" : "SSH",
     "namespace" : "File",
     "provider" : "Apache Software Foundation"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/minio-source.kamelet.yaml 
b/library/camel-kamelets/src/main/resources/kamelets/minio-source.kamelet.yaml
index 95cdf5207..014ee7413 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/minio-source.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/minio-source.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
 
       Use it to process files that another system drops into a MinIO bucket, 
such as uploaded documents, exported reports or log files. For Amazon S3 use 
`aws-s3-source`, and for the S3 gateway of Ceph use `ceph-source`.
 
-      Output: the body is the content of the file, as bytes. The headers give 
the bucket name, the name of the file (`CamelMinioObjectName`), and its content 
type, size, ETag and last modified date.
+      Output: the body is the content of the file, as bytes, and the 
`Content-Type` header is set to `application/octet-stream`. The headers give 
the bucket name, the name of the file (`CamelMinioObjectName`), and the content 
type the file was stored with (`CamelMinioContentType`), its size, ETag and 
last modified date.
 
       Good to know: files are deleted from the bucket after they are read, 
unless `deleteAfterRead` is set to false; then the same files are read again on 
every poll, about twice a second. Only the files at the top of the bucket are 
read: a file in a folder, such as `reports/january.csv`, is not.
     required:
@@ -82,6 +82,7 @@ spec:
         default: false
   dataTypes:
     out:
+      default: binary
       headers:
         CamelMinioBucketName:
           title: Bucket Name
@@ -103,6 +104,11 @@ spec:
           title: ETag
           description: The ETag of the file, which changes when its content 
changes.
           type: string
+      types:
+        binary:
+          format: "application-octet-stream"
+          description: "The content of the file, as bytes."
+          mediaType: application/octet-stream
   dependencies:
   - "camel:minio"
   - "camel:kamelet"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/ssh-source.kamelet.yaml 
b/library/camel-kamelets/src/main/resources/kamelets/ssh-source.kamelet.yaml
index ccf1db038..e6407c82d 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/ssh-source.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/ssh-source.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
 
       Use it to watch a server without installing anything on it, for example 
check the free disk space, the state of a service or the last lines of a log 
file every minute. To run a command for each incoming message instead, use 
`ssh-sink`.
 
-      Output: the body is what the command printed on its standard output, as 
text. The `CamelSshExitValue` header holds the exit code of the command, and 
`CamelSshStderr` what it printed on its standard error, as a stream.
+      Output: the body is what the command printed on its standard output, as 
text, and the `Content-Type` header is set to `text/plain`. The 
`CamelSshExitValue` header holds the exit code of the command, and 
`CamelSshStderr` what it printed on its standard error, as a stream.
 
       Good to know: it runs `pollCommand` with the rights of `username`, so 
log in with an account that may do only what is needed. It runs it every half 
second by default; set `delay` to how often you need it. A command that fails 
still sends a message, with its exit code in `CamelSshExitValue`. Log in with 
`password`, or with a private key in `privateKeyResource` when the server does 
not take passwords; when a key is set, the password is not used. The key of the 
server is checked only  [...]
     required:
@@ -110,6 +110,7 @@ spec:
         example: df -h /
   dataTypes:
     out:
+      default: text
       headers:
         CamelSshExitValue:
           title: Exit Code
@@ -119,6 +120,11 @@ spec:
           title: Standard Error
           description: What the command printed on its standard error, as a 
stream.
           type: object
+      types:
+        text:
+          format: "text-plain"
+          description: "What the command printed on its standard output, as 
text."
+          mediaType: text/plain
   dependencies:
     - "camel:ssh"
     - "camel:kamelet"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.citrus.it.yaml
index 3ee41ec75..0444a17db 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.citrus.it.yaml
@@ -72,7 +72,7 @@ actions:
             - name: "X-Body-Type"
               value: '[B'
             - name: "X-Content-Type"
-              value: 'ct='
+              value: 'ct=application/octet-stream'
             - name: "X-Minio-Bucket-Name"
               value: 'minio-source-bucket'
             - name: "X-Minio-Object-Name"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml 
b/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml
index 744ef6ca0..5d0f9c2d9 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml
@@ -31,6 +31,9 @@
         - setHeader:
             name: X-Content-Type
             simple: "ct=${header.Content-Type}"
+        # the HTTP server reads an application/octet-stream body as bytes: 
send the content as text
+        - removeHeader:
+            name: Content-Type
         # Camel headers are not sent over HTTP: copy them
         - setHeader:
             name: X-Minio-Bucket-Name
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.citrus.it.yaml
similarity index 79%
copy from 
tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
copy to 
tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.citrus.it.yaml
index a16ce79e6..73cf2f737 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.citrus.it.yaml
@@ -15,8 +15,8 @@
 # limitations under the License.
 # ---------------------------------------------------------------------------
 
-name: ssh-source-route-test
-description: 'ssh-source runs the command on the server and sends what it 
printed as text, with its exit code and standard error'
+name: sftp-source-stream-route-test
+description: 'sftp-source with streamDownload reads the file in the directory 
on the SFTP server as a stream, kept by stream caching, with its name in the 
file, ce-file and CamelFileName headers'
 actions:
   # Start the OpenSSH server (port 2222), with the user citrus, whose password 
has characters that have a
   # meaning in an endpoint address
@@ -52,7 +52,7 @@ actions:
         run:
           waitForRunningState: false
           integration:
-            file: "ssh/ssh-source-route.yaml"
+            file: "ssh/sftp-source-stream-route.yaml"
             systemProperties:
               properties:
                 - name: "http.sink.url"
@@ -64,7 +64,7 @@ actions:
                 - name: "ssh.known.hosts"
                   value: "${ssh.known.hosts}"
 
-  # The body is what the command printed, as text, with its exit code and what 
it printed on the standard error
+  # The source gives the content of the file as a stream, with its name, which 
has a space, and its size
   - http:
       server: "fileHttpServer"
       receiveRequest:
@@ -73,18 +73,21 @@ actions:
           type: "plaintext"
           headers:
             - name: "X-Body-Type"
-              value: 'java.lang.String'
+              value: 'org.apache.camel.converter.stream.InputStreamCache'
             - name: "X-Content-Type"
               value: 'ct='
-            - name: "X-Ssh-Exit-Value"
-              value: '0'
-            - name: "X-Ssh-Stderr-Type"
-              value: 'java.io.ByteArrayInputStream'
-            - name: "X-Ssh-Stderr"
-              value: 'check done'
+            - name: "file"
+              value: 'order 1.csv'
+            - name: "ce-file"
+              value: 'order 1.csv'
+            - name: "X-File-Name"
+              value: 'order 1.csv'
+            - name: "X-File-Length"
+              value: '15'
           body:
             data: |
-              disk ok
+              id,item
+              1,book
   - http:
       server: "fileHttpServer"
       sendResponse:
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml 
b/tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.yaml
similarity index 67%
copy from 
tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml
copy to 
tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.yaml
index 744ef6ca0..75cd90e11 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/minio/minio-source-route.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/ssh/sftp-source-stream-route.yaml
@@ -17,12 +17,18 @@
 
 - route:
     from:
-      uri: "kamelet:minio-source"
+      uri: "kamelet:sftp-source"
       parameters:
-        endpoint: '{{s3.url}}'
-        accessKey: '{{s3.accessKey}}'
-        secretKey: '{{s3.secretKey}}'
-        bucketName: 'minio-source-bucket'
+        connectionHost: '{{ssh.host}}'
+        connectionPort: '{{ssh.port}}'
+        username: 'citrus'
+        # a password with characters that have a meaning in an endpoint address
+        password: 's3cr&t+pw'
+        directoryName: 'orders'
+        # the file is read from the server while it is handed on, as a stream
+        streamDownload: true
+        # the key of the server is checked against this known_hosts file
+        knownHostsUri: 'file://{{ssh.known.hosts}}'
       steps:
         # what the Kamelet gives: the Java type of the body and the 
Content-Type
         - setHeader:
@@ -33,21 +39,12 @@
             simple: "ct=${header.Content-Type}"
         # Camel headers are not sent over HTTP: copy them
         - setHeader:
-            name: X-Minio-Bucket-Name
-            simple: "${header.CamelMinioBucketName}"
+            name: X-File-Name
+            simple: "${header.CamelFileName}"
         - setHeader:
-            name: X-Minio-Object-Name
-            simple: "${header.CamelMinioObjectName}"
-        - setHeader:
-            name: X-Minio-Content-Length
-            simple: "${header.CamelMinioContentLength}"
-        - setHeader:
-            name: X-Minio-ETag
-            simple: "${header.CamelMinioETag}"
-        - setHeader:
-            name: X-Minio-Content-Type
-            simple: "${header.CamelMinioContentType}"
-        # give the HTTP server text
+            name: X-File-Length
+            simple: "${header.CamelFileLength}"
+        # the body is a stream: give the HTTP server text
         - convertBodyTo:
             type: "java.lang.String"
         - to:
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
index a16ce79e6..5af9ea9c9 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/ssh/ssh-source-route.citrus.it.yaml
@@ -75,7 +75,7 @@ actions:
             - name: "X-Body-Type"
               value: 'java.lang.String'
             - name: "X-Content-Type"
-              value: 'ct='
+              value: 'ct=text/plain'
             - name: "X-Ssh-Exit-Value"
               value: '0'
             - name: "X-Ssh-Stderr-Type"

Reply via email to