helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.44k stars 562 forks source link

Profile does not apply in helidon mp configuration made by meta-config.yaml #8851

Closed ahreurink closed 1 week ago

ahreurink commented 4 weeks ago

Profiles in helidon-mp yaml configuration do not override config parameters.

Environment Details


Problem Description

When using a meta-config.yml file to specify a configuration file, this configuration file does not respect profiles. If I have a value

And i run my program with said profile, currently the value without profile is active, where as I expect the profile version to be active.

Steps to reproduce

Starting from a new helion-mp project, this is how I came to the described situation:

  1. Add a config parameter with profile to microprofile-config.properties: I added for example "%dev.app.greeting=Hello-dev" after the default line "example app.greeting=Hello". When compiling, and running java -Dmp.config.profile=dev -jar target/helidon-quickstart-mp.jar, now curl http://localhost:8080/greet returns the following: {"message":"Hello-dev World!"}

  2. Add the file meta-config.yaml with reference to the default configuration filemicroprofile-config.properties:

    sources:
    - type: "classpath"
    properties:
      resource: "META-INF/microprofile-config.properties"

    When I run mvn clean package, followed by java -Dmp.config.profile=dev -jar target/helidon-quickstart-mp.jar and finally curl http://localhost:8080/greet , I would expect the same response, but the response is {"message":"Hello World!"}

ahreurink commented 4 weeks ago

The bug reproduces if I use mp-meta-config.yaml (I think this is how I should have done it to begin with).

However, if I use mp-meta-config.yaml and add add-default-sources: true, the expected behavior does occur, even if there is no microprofile-config.properties present

tomas-langer commented 1 week ago

Meta-config yaml replaces other configuration options of MP Config. You can configure profile in the meta-config.yaml file itself (and have a different file on each environment).

ahreurink commented 1 week ago

Thank you for your response Thomas. I see I should have added system-properties as a source.