tools400 opened a new pull request, #27790:
URL: https://github.com/apache/camel/pull/27790

   # Description
   
   JIRA: [CAMEL-25498](https://issues.apache.org/jira/browse/CAMEL-25498)
   
   ## What is wrong
   
   `camel export --runtime=quarkus` writes every `quarkus.*` key except 
`quarkus.hawtio.*` through `StringHelper.camelCaseToDash` 
(`ExportQuarkus.applicationPropertyLine`). That turns each upper-case letter 
into a dash and the lower-case letter, and each underscore into a dash, also in 
the names a key holds: log categories, datasource names, map keys. Quarkus 
takes those names literally, so the exported project configures something else:
   
   | Key in the project | Exported as |
   |---|---|
   | `quarkus.swagger-ui.urls.Camel` | `quarkus.swagger-ui.urls.-camel` |
   | `quarkus.log.category."com.example.MyRoute".level` | 
`quarkus.log.category."com.example.-my-route".level` |
   | `quarkus.datasource.Orders.db-kind` | `quarkus.datasource.-orders.db-kind` 
|
   | `quarkus.rest-client."org.acme.MyClient".url` | 
`quarkus.rest-client."org.acme.-my-client".url` |
   | `quarkus.kubernetes.env.vars.MY_VAR` | 
`quarkus.kubernetes.env.vars.-my-var` |
   | `quarkus.datasource.order_history.db-kind` | 
`quarkus.datasource.order-history.db-kind` |
   
   `camel run --runtime=quarkus` exports the project with `ExportQuarkus` as 
well (`Run.runQuarkus`) and is affected the same way. The conversion came with 
CAMEL-18322 (3.18.1), when the export read the keys into camel case; that 
reading was removed a few days later, the conversion stayed. CAMEL-22139 then 
excluded `quarkus.hawtio.*`. 4.22.1, `camel-4.22.x` and `main` are affected.
   
   ## Steps to reproduce
   
   ```shell
   camel init hello.camel.yaml
   cat > application.properties <<'EOF'
   quarkus.http.rootPath=/api
   quarkus.swagger-ui.urls.Camel=../openapi.json
   quarkus.log.category."com.example.MyRoute".level=DEBUG
   quarkus.datasource.Orders.db-kind=postgresql
   EOF
   camel export hello.camel.yaml application.properties --runtime=quarkus 
--gav=org.example:hello:1.0.0 --dir=export
   grep '^quarkus\.' export/src/main/resources/application.properties
   # quarkus.http.root-path=/api
   # quarkus.swagger-ui.urls.-camel=../openapi.json
   # quarkus.log.category."com.example.-my-route".level=DEBUG
   # quarkus.datasource.-orders.db-kind=postgresql
   ```
   
   ## Fix
   
   - `ExportQuarkus.dashQuarkusOptionNames` splits a `quarkus.*` key at the 
dots outside quotes and writes only the segments in dash case that look like a 
camel cased option name: they start with a lower-case letter and have an 
upper-case letter. `quarkus.http.rootPath` is still exported as 
`quarkus.http.root-path`.
   - Quoted segments, segments that start with an upper-case letter and 
segments without an upper-case letter are kept as they are. All keys in the 
table above are exported as written.
   - `camel.*` keys and the `quarkus.hawtio.*` exception are unchanged.
   
   The JIRA proposes two ways. This PR takes the second one, because Quarkus 
option names are dash case (see the comment on CAMEL-22139). If you prefer the 
first way, writing `quarkus.*` keys exactly as given, the change becomes a 
one-liner in `applicationPropertyLine`; then a camel cased option name such as 
`quarkus.http.rootPath` is no longer dashed.
   
   ## Behaviour change
   
   - A `quarkus.*` key whose names are quoted, start with an upper-case letter 
or have no upper-case letter is exported as written. Documented in 
`camel-4x-upgrade-guide-4_24.adoc`.
   - Unchanged, and documented in the guide as well: a name in camel case that 
starts with a lower-case letter, such as a datasource `myOrders` or 
`my_DataSource`, still looks like an option name and is dashed as a whole, 
underscores included (`my-orders`, `my-data-source`). Quoting it 
(`quarkus.datasource."myOrders".db-kind`) keeps it.
   - Also unchanged: a key with a profile prefix such as 
`%dev.quarkus.http.rootPath` is not converted at all.
   
   ## Tests
   
   | Test | Asserts |
   |---|---|
   | `ExportTest.shouldDashOnlyQuarkusOptionNames` | `camel export 
--runtime=quarkus --property ...`: `quarkus.http.rootPath` is dashed; 
`urls.Camel`, the quoted log category and the datasources `Orders`, 
`"myOrders"` and `order_history` are kept; `camel.main.streamCachingEnabled` is 
still dashed and `quarkus.hawtio.authenticationEnabled` still kept |
   | `ExportQuarkusTest.shouldDashOnlyOptionNames` (13 keys) | 
`dashQuarkusOptionNames` directly: an option name after a quoted segment with 
dots (`"org.acme.myApp".minLevel` to `min-level`), a quote that is not closed, 
empty segments, and the names that still look like option names (`myOrders`, 
`my_DataSource`) |
   
   The export test fails against `main` (`quarkus.swagger-ui.urls.Camel` is 
missing from the exported `application.properties`). Its `camel.*` and 
`quarkus.hawtio.*` checks pass there, and each fails when its branch in 
`applicationPropertyLine` is taken out. In `dsl/camel-jbang/camel-jbang-core`, 
`ExportTest`, `ExportQuarkusTest`, `ExportHelperTest`, `ExportMainJibTest`, 
`ExportMainJkubeTest` and `QuarkusPlatformMixinTest` are green on top of the 
current `main` (159 tests). I left out the five 
`ExportTest.shouldExportWith*Repos*` tests, because they download from 
repositories that the network I tested in does not answer; they only check the 
repositories in the generated `pom.xml`. A root `mvn clean install -DskipTests` 
leaves no uncommitted changes. With the fix, the reproducer above run with the 
locally built Camel CLI 4.23.0-SNAPSHOT exports the keys as written, except 
`quarkus.http.root-path=/api`; with Camel CLI 4.22.1 it prints the output shown.
   
   _Changes prepared with Claude Code on behalf of @tools400._
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other 
small items do not require a JIRA issue. In this case your pull request should 
address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] 
Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the 
appropriate JIRA issue.
   -->
   
   - [x] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
   <!--
   You can run the aforementioned command in your module so that the build 
auto-formats your code. This will also be verified as part of the checks and 
your PR may be rejected if if there are uncommited changes after running `mvn 
clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at 
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   


-- 
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