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

Spring Cloud Config Server - Multi-File Composition / Importing #2335

Open
tomcruise81 opened this issue Oct 6, 2023 · 6 comments
Open

Spring Cloud Config Server - Multi-File Composition / Importing #2335

tomcruise81 opened this issue Oct 6, 2023 · 6 comments

Comments

@tomcruise81
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm trying to group blocks of configuration into individual files for clarity. Unfortunately, I can't find any documentation on if Spring Cloud Config Server offers the ability to reference other Spring Cloud Config Server files from within a given file and have them imported / included in the final rendered file.

Describe the solution you'd like
Much in the same way that Spring Boot offers the spring.config.import option, I'd like to see a way to import or include populated Spring Cloud Config Server files part-a.properties & part-b.properties in template.properties. Maybe name it ${spring.cloud.config.import}

# part-a.properties
property.a=SOME_VALUE_A
# part-b.properties
property.b=SOME_VALUE_B
# template.properties

${spring.cloud.config.import=part-a.properties}

${spring.cloud.config.import=part-b.properties}

Spring Cloud Config Server rendered template.properties:

# template.properties

# part-a.properties
property.a=SOME_VALUE_A

# part-b.properties
property.b=SOME_VALUE_B

Describe alternatives you've considered
Specifying every single property that we want to include is cumbersome and lacks clarity.

@ryanjbaxter
Copy link
Contributor

Even spring.config.import does not do this, when you use spring.config.import each import statement is still its own property source.

You can have the config server serve up the files in your example by making a request to /part/a,b. In other words if the client had an application name part and activated profiles a, and b, that would cause the config server to return both configuration files in its list of property sources.

@tomcruise81
Copy link
Contributor Author

tomcruise81 commented Oct 6, 2023

Thanks for the input @ryanjbaxter.

One of the benefits of Spring Cloud Config Server is that it doesn't just work with Spring clients but can serve up populated config files directly to be consumed by other types of applications - hence my desire for the rendered result rather than the notion of multiple property sources.

Trying to include the multiple profiles seems to only render the results of the first matching file/profile.

@ryanjbaxter
Copy link
Contributor

So are you using the config server to serve up specific files? Can you provide an example of the requests you are making to the config server?

@tomcruise81
Copy link
Contributor Author

tomcruise81 commented Oct 6, 2023

https://spring-cloud-config-server.somedomain.com/GIT_PROJECT%28_%29GIT_REPO/PROFILE/BRANCH/template.properties

Where:

  • PROFILE equates to one of our lifecycle environments - dev, val, int, prd
  • BRANCH is the Git branch (we have Spring Cloud Config Server tied to a Bitbucket / Git backend)

@ryanjbaxter
Copy link
Contributor

Essentially what you are looking for a way to return multiple config files in a single request, correct?

@tomcruise81
Copy link
Contributor Author

tomcruise81 commented Oct 6, 2023

In the simplest sense - yes.

But I could see the benefit to doing something like:

# template.properties

info.app.name=${application.name}
info.app.version=${application.version}

${spring.cloud.config.import=part-a.properties}

${spring.cloud.config.import=part-b.properties}

getting rendered to:

# template.properties

info.app.name=Something Useful
info.app.version=1.2.3.4

# part-a.properties
property.a=SOME_VALUE_A

# part-b.properties
property.b=SOME_VALUE_B

where there's a mix of populated properties and resolved property file contents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants