Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get single property values from Spring Cloud Config Server?

I would like to get single property values from Spring Cloud Config Server with a wget/curl call from the command line.

Single values because otherwise I have to parse them out of the response and I want to keep the bash-scripts as simple as possible.

The documentation of Spring Cloud Config Server states the possibilities of the REST API as follows

/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties

Is there any trick to get a single value? I searched quite a bit but found nothing. Not a huge need as it seems.

Or can I extend the EnvironmentController of the Config Server to implement this feature? I didn't found any resources about extending the REST API of the Config Server.

Thanks for your help

like image 314
burki Avatar asked Aug 31 '17 15:08

burki


People also ask

Does spring cloud config override properties?

Overriding the Values of Remote Properties If you want to allow your applications to override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting spring. cloud. config.

What is the advantage using spring cloud config?

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments.

When should I use spring cloud config server?

Spring Cloud Config Server is used to provide server-side and client-side support for externalized configuration in a distributed system. So when you have multiple microservices, and you want to easily control the configuration for all of them at one go - you'll mostly be looking at Spring Cloud Config Server.


2 Answers

To answer my own question: Spring Config Server has some kind of template mechanism. With this you can basically serve whatever you want.

In the documentation this is not very obvious because it is called Serving Plain Text: http://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.3.4.RELEASE/single/spring-cloud-config.html#_serving_plain_text

Even the example in the documentation is not serving plain text, but a structured configuration format.

like image 164
burki Avatar answered Oct 11 '22 20:10

burki


just to give an example to @burki's answer, you can put a file named foo-details.json and the contents can look like this:

{
    "my-custom-key": "${some.value.from.another.upstream.config:default-value}"
}

and when you GET that file from the config server, it will have replace values:

https://config.your-company.com/foo-app/some-profile/some-branch-name/foo-details.json

like image 31
Jason Avatar answered Oct 11 '22 20:10

Jason