Config server does some unique things with property sources.
First, for security reasons, we check that a given property source came from an allowed location, such as classpath:/config/
This is currently done, since boot 2.4.x, with a regex against the name Config resource '(.*?)' via location '(.*)'
. Previously it was done with custom string matching.
Second, as part of config server taking advantage of #25766, it will need to match a profile against the name as well (eg. dev
matched against classpath:/config/profilesample-dev.yml
).
StandardConfigDataReference
contains references to both of these pieces of data. If those could be exposed somehow in StandardConfigDataLoader
that would be extremely helpful.
Maybe something like the OriginLookup
interface that OriginTrackedMapPropertySource
could implement, or some other wrapper around PropertySource
.
Comment From: philwebb
The regex code currently used is in NativeEnvironmentRepository
Comment From: philwebb
It turns out that most of the code that Spring Cloud needs is already available. If this line is updated to use the applyTo
method that accepts a ConfigDataEnvironmentUpdateListener
then a link between the PropertySource
and the ConfigDataLocation
/ConfigDataResource
can be made.
The only thing that's missing is being able to get the profile. I'll do that by adding a method to StandardConfigDataResource
. I kind of consider this a bug because it's something we should have done when fixing #25766.