davsclaus opened a new pull request, #30217: URL: https://github.com/apache/camel/pull/30217
_Claude Code on behalf of davsclaus_ [CAMEL-27069](https://issues.apache.org/jira/browse/CAMEL-27069) ### Problem camel-main bound an OS environment variable to its options by turning each `_` into a dot, so an option name with more than one word had to be written without underscores (`CAMEL_MAIN_SHUTDOWNTIMEOUT`). The vault components document their variables with underscores between the words, and read them with `System.getenv`: `CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY`, `CAMEL_VAULT_GCP_PROJECT_ID`, `CAMEL_VAULT_AWS_ACCESS_KEY`, `CAMEL_VAULT_AZURE_TENANT_ID`, `CAMEL_VAULT_IBM_EVENTSTREAM_BOOTSTRAP_SERVERS` and more. camel-main picks them up too, as they start with `CAMEL_VAULT_`, and a Camel Main application with one of them set failed at startup: ``` java.lang.IllegalArgumentException: Cannot find getter method: service on bean: class org.apache.camel.vault.GcpVaultConfiguration when binding property: service.account.key ``` The `CAMEL_COMPONENT_*`, `CAMEL_DATAFORMAT_*` and `CAMEL_LANGUAGE_*` variables already allow underscores between the words of an option. ### Change - `PrepareCamelMainMojo` also writes the keys of the camel-main options (599, one per line) to `org/apache/camel/main/main-options.properties`, next to `components.properties`. Reading them does not need the 245 KB metadata JSON at startup. - `MainHelper.loadEnvironmentVariablesAsProperties` maps a variable through `envVariableToKey`: when the variable matches the key of a camel-main option with dots, dashes and underscores ignored, it gets that key, so `CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY` and `CAMEL_VAULT_GCP_SERVICEACCOUNTKEY` both set `camel.vault.gcp.serviceAccountKey`. Any other variable (such as `CAMEL_BEANS_*`) keeps the old mapping. The key list is loaded lazily, only when a variable is mapped. No two of the 599 keys collide; if two ever did, they would keep the old mapping. - Upgrade guide 4.24: the new form, and that the documented vault variables now configure the `camel.vault.*` options instead of failing the startup. ### Tests - `MainHelperTest.testEnvVariableToKeyWithUnderscoresBetweenWords`: the vault, IBM event stream and `camel.main` variables, with and without underscores between the words, a key with a dash (`camel.cluster.jgroups-raft`), and variables that match no option. - New `MainEnvVarUnderscoreOptionTest` (end to end, sets real environment variables like `MainEnvVarComponentConfigTest`): `CAMEL_VAULT_GCP_SERVICE_ACCOUNT_KEY`, `CAMEL_VAULT_GCP_PROJECT_ID` and `CAMEL_MAIN_SHUTDOWN_TIMEOUT` configure the GCP vault and the shutdown timeout. It fails without the change with `Cannot find getter method: project ... project.id`. camel-main (338 tests) passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
