Reputation: 13501
When setting environment variables for properties with hyphens, such as:
quarkus.datasource.db-kind=postgresql
I would expect it to be set as:
export QUARKUS_DATASOURCE_DB_KIND=postgresql
However, that results in an the following message:
Unrecognized configuration key "quarkus.datasource.db.kind" was provided; it will be ignored;
All other properties, without hyphens, are passed correctly.
It also happens for other properties:
export QUARKUS_DATASOURCE_JDBC_MIN_SIZE=10
export QUARKUS_DATASOURCE_JDBC_INITIAL_SIZE=20
export QUARKUS_DATASOURCE_JDBC_MAX_SIZE=1000
...
Unrecognized configuration key "quarkus.datasource.jdbc.max.size" was provided;
Unrecognized configuration key "quarkus.datasource.jdbc.min.size" was provided;
Unrecognized configuration key "quarkus.datasource.jdbc.initial.size" was provided;
Workaround: Rename the environment variables and pass them into application.properties, with the hyphen names:
quarkus.datasource.jdbc.initial-size=${DATASOURCE_JDBC_INITIAL_SIZE}
quarkus.datasource.jdbc.min-size=${DATASOURCE_JDBC_MIN_SIZE}
quarkus.datasource.jdbc.max-size=${DATASOURCE_JDBC_MAX_SIZE}
What is the proper conversion? Is it documented somewhere?
Upvotes: 5
Views: 6933
Reputation: 175
In general, properties with hyphens are tricky to map correctly as it is not clear which representation to map to. So try to avoid hyphens if you can.
See this issue for more info.
Upvotes: 0
Reputation: 493
Try replacing hyphen with underscore. It works in my case despite the warning message.
application.yml
quarkus:
swagger-ui:
enable: false
docker run
$ docker run -d -e QUARKUS_SWAGGER_UI_ENABLE=true -p 8080:8080 sample.com/foo
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-06-09T05:34:55.192Z WARN [io.qua.config] Unrecognized configuration key "quarkus.swagger.ui.enable" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2021-06-09T05:35:12.947Z INFO [sam.com.access-log] 192.168.113.42 - - "GET /q/openapi HTTP/1.1" 200 14464 -
Upvotes: 1
Reputation: 3890
Quarkus follows the naming conventions from MicroProfile:
Exact match (i.e. com.ACME.size)
Replace each character that is neither alphanumeric nor _ with _ (i.e. com_ACME_size)
Replace each character that is neither alphanumeric nor _ with _; then >convert the name to upper case (i.e. COM_ACME_SIZE)
Thus QUARKUS_DATASOURCE_DB_KIND is correct, but that property is a build time only property as seen with the lock icon on https://quarkus.io/guides/all-config#quarkus-datasource_quarkus.datasource.db-kind
Thus you would need to set this at build time to have effect.
That said, the error message is not great and if you can confirm you are trying to set this a runtime not build time then please open issue with your context and suggest the error message is improved to highlight it is or could be a build time only property.
Upvotes: 2
Reputation: 559
I think most shells consider the hyphen to be an invalid identifier. Depending on how quarkus is run, (CLI?), you can do something like
env "QUARKUS_DATASOURCE_DB-KIND=postgresql" quarkus
This makes some assumptions about how the env variables are converted into configuration keys. Based on the information you provided, it looks like cast to lowercase and replace _
with .
? Who knows what it will do to the hyphen
Upvotes: -1