-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config mapping for java.util.Map
s that also have an "unnamed" entry
#32295
Comments
Support in SmallRye Config: @yrodiere would you like to take a look? One difference is I named the annotation |
@radcortez Sure the name looks fine. I can try to use it in Quarkus if you want, would it work if I just built locally from your PR and bumped the version in Quarkus? Or are there also breaking changes that will prevent that from working? |
Yes, it should work without any additional changes. |
Thanks. I'll report back on Monday. |
@radcortez Looks good, thanks a lot! We'll need adjustment to doc generation in Quarkus, but that can wait; see #32854 for details. |
Great! Good to hear. Yes, we need to figure out what to do with documentation. Also, I still need to add the ability to retrieve / create a default entry. |
Description
In several extensions, we need to provide named configuration sections, while still allowing a "default", unnamed section with the same prefix.
E.g. for Hibernate Search/ORM we have a concept of persistence units, configured with the prefix
quarkus.hibernate-search-orm
.There's a default persistence unit, configured like this:
And there are (optional) named persistence units, configured like this:
We usually end up implementing this as two separate methods, plus another one to aggregate the whole thing by hand:
And then in extension code we do something like:
Since that's a rather frequent use case, maybe we could introduce a shortcut that would directly put the "root"/default entry in the map, with a provided key?
It would be nice to introduce this before we migrate all extensions to
@ConfigMapping
, so we can simplify extension config while we migrate.See also https://github.com/quarkusio/quarkus/pull/32276/files#r1154222403
Implementation ideas
E.g.:
@WithRootEntry
here would mean "with the same prefix, we also allow configuring a map entry without a name, with the same structure". Andkey = ...
would mean "I want the unnamed map entry to be added to the map with this key, which I don't expect to conflict with named entries".The text was updated successfully, but these errors were encountered: