Serhii
Serhii

Reputation: 7543

How to combine project yml configurations for Quarkus in profile.yml

We've used quarkus as basement for new project services. Considering its configuration, it can be configured using yml files.

To follow this way, added

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-config-yaml</artifactId>
</dependency>

yml configuration applied. To improve this configuration, I'd like to have a chance put some configurations in different files and combine them together, depending on...

For example I need next configurations in separate files:

I'd like to manage them in my main profile configuration like other profiles imports

quarkus:
  profiles:
    include: postgre-ds, oracle-ds

or like imports from classpath

quarkus:
  import:
    config: classpath:application-postgre-ds.yml;application-oracle-ds.yml

but haven't detected nothing useful in their documentation.

I hope I missed correct instruction and someone would help me make working combined configuration.

Upvotes: 0

Views: 1678

Answers (1)

Roberto Cortez
Roberto Cortez

Reputation: 1163

This is partially supported by Quarkus:

It is possible to have specific configurations files per profile: https://quarkus.io/guides/config-reference#profile-aware-files

But in Quarkus, you can only have a single profile active. For instance, if the profile dev is active, Quarkus will load configurations both from application-dev.properties and the main file application.properties. Configuration from the profile-aware file has priority.

There is also the notion of a parent profile, which you can use to share common configuration across multiple profiles: https://quarkus.io/guides/config-reference#parent-profile

If you really need the multi-profile approach, as I said, Quarkus does not officially support it, but it is supported by SmallRye Config (used by Quarkus): https://smallrye.io/smallrye-config/latest/config/profiles/#multiple-profiles. It should work for this use case, but it is not integrated into Quarkus, so some Quarkus features around configuration profiles will not work properly. For instance, the @IfBuildProfile and @UnlessBuildProfile annotations, but there are more cases. So use it carefully.

Upvotes: 1

Related Questions