Using consul config (format: FILE), in ConsulConfigurationClient class the resolveEnvironment method should correctly determine the envName variable allowing it to find the appropriate environment configuration.
Running the application with MICRONAUT_ENVIRONMENTS={ENV_NAME} should result in overwriting the default properties with those from the environment file.
I created the Pull Request #532.
Actual Behaviour
Running the application with MICRONAUT_ENVIRONMENTS={ENV_NAME} with the existing code, the value of the envName variable will never be resolved correctly.
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. If the same properties will be used, then result of that property will be from standard config file, not file with environment.
Steps To Reproduce
Create standard configuration for service (ex. my-service.yaml (! no application.yml)) with value:
mongodb:
uri: mongodb://127.0.0.1:27017/standard
Create configuration with environment (ex. my-service-prod.yml)
mongodb:
uri: mongodb://127.0.0.1:27017/prod
Run the application with MICRONAUT_ENVIRONMENTS=prod
The environment will not be considered appropriate. If the same properties will be used, then result will be connecting to db named standard instead of prod.
Expected Behavior
Using consul config (format: FILE), in
ConsulConfigurationClient
class theresolveEnvironment
method should correctly determine theenvName
variable allowing it to find the appropriate environment configuration.Running the application with MICRONAUT_ENVIRONMENTS={ENV_NAME} should result in overwriting the default properties with those from the environment file.
I created the Pull Request #532.
Actual Behaviour
Running the application with MICRONAUT_ENVIRONMENTS={ENV_NAME} with the existing code, the value of the envName variable will never be resolved correctly.
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. If the same properties will be used, then result of that property will be from standard config file, not file with environment.
Steps To Reproduce
The environment will not be considered appropriate. If the same properties will be used, then result will be connecting to db named
standard
instead ofprod
.Environment Information
No response
Example Application
No response
Version
3.8.7 - *