Skip to content
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

Load additonal config searching parent recursively #32479

Open
xenoterracide opened this issue Sep 22, 2022 · 2 comments
Open

Load additonal config searching parent recursively #32479

xenoterracide opened this issue Sep 22, 2022 · 2 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@xenoterracide
Copy link
Contributor

xenoterracide commented Sep 22, 2022

Sorry if this turns out to be a question Andy, seems like a feature

I'd like to be able to have spring search for a profile specific file, by searching upwards, like git will for .gitignore.

Something like file:optional-parent:application-${profile}.properties

this would be useful for things like monorepo support and developer secure credential configuration that works for all clients (cli, IDE, etc). We actually have a multi monorepo situation (libraries and apps)

current workaround

@SpringBootApplication
@EnableConfigurationProperties
@ConfigurationPropertiesScan
@PropertySource("file:\${HOME}/.e1-application.properties")
open class TestApplication

@Suppress("SpreadOperator")
fun main(args: Array<String>) {
  runApplication<TestApplication>(*args)
}

If this is already possible without writing more code, and without customizing any clients like the IDE, can you please put it in the documentation

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 22, 2022
@snicoll snicoll changed the title [Feature] load additonal config searching parent recursively Load additonal config searching parent recursively Sep 23, 2022
@philwebb
Copy link
Member

We don't currently support searching upwards for files. If we wanted to add support we'd probably need to change StandardConfigDataLocationResolver and I think we'd want to make it opt-in rather than a default.

If you want to do this currently, you might be able to use relative import. E.g. in the client app you'd have application.properties with the following:

spring.config.import=../application.properties

That would pick up a shared application.properties (and all profile specific variants) from the parent directory which could contain all the credential properties.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Sep 29, 2022
@xenoterracide
Copy link
Contributor Author

xenoterracide commented Sep 29, 2022

When I tried to do that I didn't seem to be able to figure out the depth. It seemed like perhaps it wasn't consistently using the same directory between IntelliJ and just running as Gradle normally. In fact I'm not sure the depth would be consistent between tests. This is why I think recursive searching would be a better solution, as I did actually try this.

@philwebb philwebb self-assigned this Nov 14, 2022
@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants