micronaut-projects / micronaut-discovery-client

Micronaut's Discovery Client
Apache License 2.0
22 stars 20 forks source link

Fix resolveEnvironment method to get proper envName from fileName #532

Closed atrzcinski closed 10 months ago

atrzcinski commented 1 year ago

With the existing code, the value of the envName variable will never be resolved correctly because the resolveEnvironment method will get the value of the fileName variable.

For example: if the name of the configuration file is my-service-prod.yaml (where prod is the name of the environment) and we provide fileName as a parameter (value is my-service-prod) instead of finalName (value is my-service[alpha]), then resolveEnvironment method will not be able to find environment.

The effect is that consul will overwrite the environment configuration with the standard configuration (e.g. my-service.yaml), i.e. the environment configuration will not be considered appropriate.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

atrzcinski commented 1 year ago

Sorry for delay with writing tests. I implemented second test with v2 suffix. It shows, that different application-specific file name affects the final effect, so order of propertySources are different. With this fix, the priority parameter of the propertySource will be valid, so sorting will always be deterministic.

atrzcinski commented 10 months ago

Hi,

@jeremyg484 When do you plan to merge this change?