Spring Cloud Config - Serving multiple applications which has multiple configuration files

Viewed 498

Currently we are planning to externalize configurations related to multiple our applications with the help of Spring Cloud Config. But we are having an issue because for some of applications, we are maintaining multiple configuration files like below

application-a
  - abc-config.yml
  - bca-config.yml
  - cab-config.yml

application-b
  - xyz-config.yml
  - yzx-config.yml
  - zxy-config.yml

We know that multiple files can be loaded by a client application by defining spring.cloud.config.name like below but it restricts to a single application

spring.cloud.config.name=abc-config,bca-config,cab-config

So far the best solution we found is using the pattern matching feature with renaming each config file related to each application with a prefix or suffix to identify each application like below

application-a
  - app-a-abc-config.yml
  - app-a-bca-config.yml
  - app-a-cab-config.yml

application-b
  - app-b-xyz-config.yml
  - app-b-yzx-config.yml
  - app-b-zxy-config.yml

Then based on the pattern check we use different git repos for different application like below

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/sample/common-repo
          repos:
            application-a:
              pattern:
                - '*app-a*'
              uri: https://github.com/sample/app-a-repo
            application-b:
              pattern:
                - '*app-b*'
              uri: https://github.com/sample/app-b-repo

We need to know whether is there any other cleaner (without renaming config files) and easier way to do this. May be a solution provided by Spring Cloud Config itself for a scenario like this.

0 Answers
Related