tarilabs opened a new issue, #3981:
URL: https://github.com/apache/camel-k/issues/3981

   I've partially discussed this with @lburgazzoli, currently it's not possible 
to make use of $subject as the GoLang would serialize any yaml in its GoLang 
string format --iiuc.
   /cc @valdar @danielezonca
   
   I have a Kamelet defined as:
   
   ```yaml
   apiVersion: camel.apache.org/v1alpha1
   kind: Kamelet
   metadata:
     name: mmk
     labels:
       camel.apache.org/kamelet.type: "action"
   spec:
     definition:
       title: "mmk"
       description: prova
       properties:
         kdtable:
           title: prova
           description: prova
           type: object
     dependencies:
     - "camel:core"
     - "camel:kamelet"
     - "github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT"
     template:
       beans:
         - name: mmbean
           type: '#class:org.drools.yard.kdtable.KdtableProcessor'
           properties:
             kdtable: '{{kdtable}}'
       from:
         uri: "kamelet:source"
         steps:
         - process:
             ref: '{{mmbean}}'
         - to: "log:info"
   ```
   
   I want to use the property `kdtable` in the Kamelet binding as a YAML.
   Currently the only workaround is to supply its value as a string [block] in 
order not to be passing through some serialization of the GoLang:
   
   ```yaml
   apiVersion: camel.apache.org/v1alpha1
   kind: KameletBinding
   metadata:
     name: timer-source-binding
   spec:
     source:
       ref:
         kind: Kamelet
         apiVersion: camel.apache.org/v1alpha1
         name: timer-source
       properties:
         message: hello world
         period: 5000
     steps:
       - ref:
           kind: Kamelet
           apiVersion: camel.apache.org/v1alpha1
           name: mmk
         properties:
           # set as block string (undesirable, but the only available current 
workaround)
           kdtable: |
             type: DecisionTable
             inputs: ['Age', 'Previous incidents?']
             rules:
             - when: ['<21', false]
               then: 800
             - when: ['<21', true]
               then: 1000
             - when: ['>=21', false]
               then: 500
             - when: ['>=21', true]
               then: 600
     sink:
       ref:
         kind: Kamelet
         apiVersion: camel.apache.org/v1alpha1
         name: mmk
       properties:
         # set as yaml, unfortunately it is not deserialized as a JSONNode or 
Map in Java, it is serialized as string by GoLang --iiuc
         kdtable:
             type: DecisionTable
             inputs: ['Age', 'Previous incidents?']
             rules:
             - when: ['<21', false]
               then: 800
             - when: ['<21', true]
               then: 1000
             - when: ['>=21', false]
               then: 500
             - when: ['>=21', true]
               then: 600
   ```
   
   My processor is defined as:
   
   ```java
   public class KdtableProcessor implements Processor {
   
       private Object kdtable;
   
       @Override
       public void process(Exchange exchange) throws Exception {
           LOG.info("this processor/bean field 'kdtable' was set to: {}", 
kdtable);
           LOG.info("this processor/bean field 'kdtable' class is: {}", 
kdtable.getClass());
   
   //... and getters, setters, etc.
   ```
   
   The output of the above binding is:
   
   ```
   2023-01-16 15:38:22,557 INFO  [org.dro.yar.kdt.KdtableProcessor] (Camel 
(camel-1) thread #1 - timer://tick) this processor/bean field 'kdtable' was set 
to: type: DecisionTable
   inputs: ['Age', 'Previous incidents?']
   rules:
   - when: ['<21', false]
     then: 800
   - when: ['<21', true]
     then: 1000
   - when: ['>=21', false]
     then: 500
   - when: ['>=21', true]
     then: 600
   2023-01-16 15:38:22,558 INFO  [org.dro.yar.kdt.KdtableProcessor] (Camel 
(camel-1) thread #1 - timer://tick) this processor/bean field 'kdtable' class 
is: class java.lang.String
   
   ...
   
   2023-01-16 15:38:22,562 INFO  [org.dro.yar.kdt.KdtableProcessor] (Camel 
(camel-1) thread #1 - timer://tick) this processor/bean field 'kdtable' was set 
to: map[inputs:[Age Previous incidents?] rules:[map[then:800 when:[<21 false]] 
map[then:1000 when:[<21 true]] map[then:500 when:[>=21 false]] map[then:600 
when:[>=21 true]]] type:DecisionTable]
   2023-01-16 15:38:22,562 INFO  [org.dro.yar.kdt.KdtableProcessor] (Camel 
(camel-1) thread #1 - timer://tick) this processor/bean field 'kdtable' class 
is: class java.lang.String
   ```
   
   The second variation in the kamelet binding (supplying `kdtable` as yaml, 
not as a string-block) is what I want to use.
   
   - I would prefer to be deserialized in Java as a Jackson JSONNode or as a 
java.lang.Map, of the yaml originally supplied
   - if the above is not possible, I do not want the `map[ ... ]` serialization 
on the Java side in the string, and to maintain the new line and formatting 
with indentation of whitespace or tabs (so to use manually Jackson myself).
   
   Can you kindly consider amending Camel-K to support this use-case, please?
   Thanks 🙏 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to