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

   https://issues.apache.org/jira/browse/CAMEL-25381
   
   `camel validate normalize` on a Kamelet file failed with only `ERROR: Error 
normalizing files`. The command dumps the routes it loads, and a Kamelet loads 
as a route template, which was not part of the dump. It is also the command the 
compact notation warning recommends, and 179 of the 250 Kamelets in 
camel-kamelets 4.22.1 trigger that warning.
   
   **What changes:**
   - **Normalize:**
     - It dumps route templates too.
     - For a `kind: Kamelet` file, only its `spec.template` block is replaced 
by the canonical YAML DSL of the template (`KameletNormalizer`). The license 
header, metadata, definition, comments and `dependencies` stay exactly as 
written.
     - With `--output <dir>`, each Kamelet is written under its own file name. 
Without `--output`, several documents are printed as one YAML stream separated 
by `---`.
     - A `routeTemplate:` in a route file was silently dropped before; it is 
now kept in the output.
   - **camel-yaml-io:** the YAML dump writes a `kamelet:` endpoint as `uri: 
kamelet:log-sink` (or `kamelet:source`, `kamelet:sink`), not as `uri: kamelet` 
plus a `templateId` parameter. That applies to user routes using Kamelets too.
   - **camel-yaml-dsl-common:** `YamlDeserializerSupport.asMap` keeps the order 
the entries are written in (`LinkedHashMap`), so bean properties are not 
shuffled when normalized.
     - `PipeLoaderErrorHandlerTest` asserted the old `HashMap` order of a 
Pipe's properties; it now expects the declared order.
   
   **Checked on all 250 Kamelets of camel-kamelets 4.22.1** (a scratch test, 
not part of this PR):
   
   | Check | Result |
   |---|---|
   | Normalized without error | 250 of 250 |
   | Kamelets logging the compact notation warning | 179 before, 0 after |
   | Same route template after loading, original vs normalized | 77 
byte-identical |
   | The other 173 | differ only in how endpoint uris are written: a path 
option as a parameter, secrets in `RAW()`, sorted options. All 173 parse 
through the Camel catalog to the same endpoint options. |
   
   A route using the normalized `timer-source` and `log-sink` (both with path 
options) runs as before.
   
   **Tests:**
   - `YamlNormalizeKameletTest` (5) is new.
   - Module suites pass: camel-yaml-io 177, camel-yaml-dsl-common 10, 
camel-yaml-dsl 458, camel-jbang-core 1529, camel-jbang-plugin-validate 7.
   
   **Follow-ups:**
   - camel-kamelets can now normalize its catalog with this command and check 
it in CI.
   - The command takes at most 9 files per call, so a whole catalog needs a 
loop.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m


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