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

   Hi,
   I have a Kamelet definition as:
   
   ```yaml
   apiVersion: camel.apache.org/v1alpha1
   kind: Kamelet
   metadata:
     name: kdtable
     labels:
       camel.apache.org/kamelet.type: "action"
   spec:
     definition:
       title: "Kamelet decision table with YaRD"
       description: |-
         Experimental Kamelet processor supporting (only) YaRD's decision table.
       required:
       - kdtable
       properties:
         kdtable:
           title: kdtable
           description: the YaRD's decision table element
           type: object
         expressionLang:
           title: expressionLang
           description: can be blank
           type: string
           default: "null" # <--- unable to use `null` in this kamelet 
definition
         resultKey:
           title: resultKey
           description: can be blank
           type: string
           default: kdtable
     dependencies:
     - ...
     template:
       beans:
         - name: mmbean
           type: '#class:org.drools.yard.kdtable.KdtableProcessor'
           properties:
             kdtable: '{{kdtable}}'
             expressionLang: '{{expressionLang}}'
             resultKey: '{{resultKey}}'
       from:
         uri: "kamelet:source"
   ...
   ```
   
   For the Processor, defined as a bean in the template on suggestion from 
@lburgazzoli , `expressionLang` is optional.
   
   However, despite it's not in the `spec.definition.required` of the Kamelet 
definition as a required property, I still need to assign it a `default: 
<something>` which cannot be null, empty, etc.
   
   - I've tried `default: null` and the Integration _at runtime_ complain the 
expressionLang property is not defined.
   - I've tried `default: ""` same thing.
   
   I think I was able to get it to be null by using in the _KameletBinding_ 
something ~like:
   
   ```yaml
   ref:
     kind: Kamelet
     apiVersion: camel.apache.org/v1alpha1
     name: kdtable
   properties:
     expressionLang: null
     kdtable: ...
   ```
   
   but this is not really what I want, I would like the user to ~"ignore" 
expressionLang in the end-user definition, so that the processor can establish 
some default when non-supplied.
   
   So currently I have it as:
   
   ```yaml
         expressionLang:
           title: expressionLang
           description: can be blank
           type: string
           default: "null" # unable to use `null` in this kamelet definition
   ```
   
   and then in my Processor I have to:
   
   ```java
   public class KdtableProcessor implements Processor {
       private Object kdtable;
       private String expressionLang;
       private String resultKey = "kdtable";
   
       public void setKdtable(Object kdtable) {
           if (expressionLang != null && !expressionLang.isEmpty() && 
!expressionLang.equals("null")) { 
               yard.setExpressionLang(expressionLang);
           } else {
               yard.setExpressionLang(null);
           }
   
   // ...
   ```
   
   which is very far from ideal, since I have to exclude the hard-coded 
`"null"` string as a null-value semantic.
   
   Q1. is it pragmatically possible to define a non-required property, given 
the above report, please?
   Q2. is it possible in a Processor to be notified _all the properties_ have 
been set --not at `process(Exchange exchange)` runtime, I mean at Processor 
instantiation for the bean/registry/context before the route building, please?
   
   Thanks in advance 🙏 
   /cc @valdar @danielezonca


-- 
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: commits-unsubscr...@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to