[ 
https://issues.apache.org/jira/browse/CAMEL-23666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18085496#comment-18085496
 ] 

Raymond commented on CAMEL-23666:
---------------------------------

I tried a few things, but get errors on route loading like


_Failed to resolve endpoint: \{{out}} due to: Property with key [out] not found 
in properties from text: \{{out}}"_


Some things I tried:



 
{code:java}
"{{?uri}} == null" 
{code}
_No endpoint could be found for: null, please check your classpath contains the 
needed Camel component jar._

-----------


{code:java}
disabled: {{?out}} == null 
{code}
 _Could not load Kamelet: log-sink.kamelet.yaml. Reason: Non scalar key is 
detected but it is not configured to be allowed._

-----------

 
{code:java}
- to:
                disabled: "'{{?out}}' == null"
                uri: "{{?out}}"{code}
 

_No endpoint could be found for: \{{?out}}, please check your classpath 
contains the needed Camel component jar._

 

*Using default*

I also try to set a dummy default value on the parameter:


{code:java}
out:
  title: "Sink Endpoint"
  type: "string"
  default: "log:dummy" {code}

But this also gave some error on loading the route


{code:java}
${`{{out}}` == 'log:dummy'}{code}
 

_Error parsing [mock:dummy == mock:dummy] from property \{{out}} == mock:dummy 
as a java.lang.Boolean._

--------------------- 
{code:java}
${`{{out}}` == 'log:dummy'}{code}
_because: Error parsing ['log:dummy' == 'log:dummy'] from property '\{{out}}' 
== 'log:dummy' as a java.lang.Boolean._
 
 ---------------------
disabled: "${'\{{out}}' == 'log:dummy'}" 

_Error parsing [${'log:dummy' == 'log:dummy'}] from property ${'\{{out}}' == 
'log:dummy'} as a java.lang.Boolean._

 

 

I think the issue with this is also that:

*1. Documentation*

The disabled node is practical, but not well documented (I could't find a 
page), so it's not clear what the syntax is. Is evaluated as a Java code, or as 
simple language?

*2. Pattern*

Though the _disabled_ is of course pre evaluated before the route loads, it 
could behave like an EIP such as filter:


{color:#000000}        - 
{color}{color:#008080}filter{color}{color:#000000}:{color}
{color:#000000}            
{color}{color:#008080}expression{color}{color:#000000}:{color}
{color:#000000}              
{color}{color:#008080}simple{color}{color:#000000}: "{color}{color:#0451a5}${x} 
== 'dummy'"{color}

Would be nice if disabled can do the same:


{color:#000000}        - 
{color}{color:#008080}disabled{color}{color:#000000}:{color}
{color:#000000}            
{color}{color:#008080}expression{color}{color:#000000}:{color}
{color:#000000}              
{color}{color:#008080}simple{color}{color:#000000}: "{color}{color:#0451a5}${x} 
== 'dummy'"{color}


            

> [Kamelet/Route Templates] Support optionals for endpoints uris
> --------------------------------------------------------------
>
>                 Key: CAMEL-23666
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23666
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core, camel-kamelet
>            Reporter: Raymond
>            Priority: Minor
>
> Currently Kamelets and Route Templates support optional endpoint options on 
> URI. For example:
> {code:java}
> - to:
>     uri: "aws2-s3:{{bucketNameOrArn}}"
>     parameters:
>       secretKey: "{{?secretKey}}"
>       accessKey: "{{?accessKey}}"
>       region: "{{region}}"
>       autoCreateBucket: "{{autoCreateBucket}}"
>       useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}"
>       useProfileCredentialsProvider: "{{useProfileCredentialsProvider}}"
>       useSessionCredentials: "{{useSessionCredentials}}"
>       uriEndpointOverride: "{{?uriEndpointOverride}}"
>       profileCredentialsName: "{{?profileCredentialsName}}"
>       sessionToken: "{{?sessionToken}}"
>       overrideEndpoint: "{{overrideEndpoint}}"
>       forcePathStyle: "{{forcePathStyle}}"
>       keyName: "{{?keyName}}" {code}
> All parameters that has a ? like \{{?secretKey}} are ingored when they are 
> not provided when creating a new template/kamelet. 
> Sometimes I provide a complete uri:
> {code:java}
> - to:
>     uri: "{{uri}}"{code}
> , but this endpoint is not always needed. In this case I would like to set 
> this:
> {code:java}
> - to:
>     uri: "{{?uri}}"{code}
> Where the complete node/endpoint is ignored/disabled when no uri is provided 
> or is null.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to