sksamuel / hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes
Apache License 2.0
922 stars 74 forks source link

Support loading configs via prefix #412

Closed rocketraman closed 7 months ago

rocketraman commented 7 months ago

I've taken a shot at updating Hoplite with prefix support. There is more to do on this PR (like tests), but I wanted to get some early feedback on this general approach.

This still loads everything once per prefix (and outputs multiple reports), but I think that is fine for this iteration, and we can consider a "load once and extract prefixes multiple times" improvement in a subsequent PR.

Also, I did not implement this as a Preprocessor as in this post because I don't want the dependency on the prefix to exist at ConfigLoaderBuilder time, but only at load time. This should make it easier to later just do the loading once, instead of once per prefix.

This would resolve https://github.com/sksamuel/hoplite/issues/386.

rocketraman commented 7 months ago

@sksamuel Good catch -- I don't think I had understood the code properly when I made those changes. I've pushed a new version of the branch that does not change PropertySourceLoader at all. And also: