Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml config profiles support #5159

Closed
botsteve opened this issue Oct 11, 2022 · 10 comments
Closed

Yaml config profiles support #5159

botsteve opened this issue Oct 11, 2022 · 10 comments
Assignees
Labels
2.x Issues for 2.x version branch config enhancement New feature or request

Comments

@botsteve
Copy link

botsteve commented Oct 11, 2022

Environment Details

  • Helidon MP Version: 3.0.1

I have a question regarding the profile support for yaml config sources. I know there is profile support for microprofile-config-${profile}.properties files but does this support extends also to application-${profile}.yaml files?

I know that something like this can be done using mp-meta-config file and specify the profile property and an higher ordinal value for application-${profile} files, thus providing the same functionality as mp.config.profile system property.

I think that there should be a similar profile support for yaml files using the same system property as for the properties files.

If indeed there is no support for this and it is wanted, i can further pursue this.

@romain-grecourt
Copy link
Contributor

@botsteve
Copy link
Author

botsteve commented Oct 12, 2022

Yea this can work, but by using "config.profile" system property will force the use of the Helidon SE Meta Configuration, which in turn will affect environment variable resolving and mutability. This will register only one source (MpHelidonConfigSource) instead of (MpSystemPropertiesSource, MpEnvironmentVariablesSource, YamlMpConfigSource) when config registration happens since it will no longer scan for discovered or default sources.

@klustria
Copy link
Member

Can you please review MP meta-config feature: https://helidon.io/docs/v3/#/mp/config/advanced-configuration#_creating_microprofile_config_sources_from_meta_config and see if that will meet your needs?

@botsteve
Copy link
Author

botsteve commented Oct 17, 2022

@klustria yea, this can work as I mentioned above, it is not a problem of making it work using meta-config but more of having a consistent support across different config extensions(.properties, .yaml etc...). Also I think that by having the same system property "mp.config.profile" working using different types of configs will make use of the convention over configuration model, which I think is desired. I've made a PR that can bring this enhancement.

@klustria
Copy link
Member

The problem is that the config source implementation is MP spec based, and that does not have profile anywhere in the SPI. So we do not know which profile to use. The implementation of the PR you created is depending on a system property, which is not the only way to define a profile (it can be defined in another config source). So unless the SPI contains information about which profile to use, we cannot modify it. There might be a way to do this but it may be a little complex than what you PR presents but this may need to be looked at further by the team. In the meantime, your only workaround is to use meta-config.

@botsteve
Copy link
Author

botsteve commented Oct 20, 2022

yea, I agree, the problem is the ConfigSourceProvider contract from the MP spec which doesn't provide a profile support, and indeed this doesn't cover the ConfigSource usecase, but I think the general usecase is to cover the system property use. Maybe using reflection to configure a profile field on the ConfigSourceProvider might be an option?

@botsteve
Copy link
Author

@klustria updated the PR to use reflection to set the profiles property since the MP spec doesn't cover this, this should cover the configuration from other sources besides the system as well.

@tomas-langer
Copy link
Member

Hello @botsteve, this is a limitation of MicroProfile specification and we cannot do much about it.
We may be able to implement profile based approach for our default "application.yaml" (or any application.*) through the existing spi for MpMetaConfigProvider (e.g. if not using meta config, we could create the meta configuration for the supported type and attempt to load it), as that supports profiles correctly.

@klustria
Copy link
Member

klustria commented Dec 1, 2022

This will be fixed by PR #5565 that will have a new SPI (io.helidon.config.mp.spi.MpConfigSourceProvider) that extends org.eclipse.microprofile.config.spi.ConfigSourceProvider but adds config profile support.

@klustria
Copy link
Member

klustria commented Dec 1, 2022

Closing as #5565 is merged. Will be working to port this into 3.x line.

@klustria klustria closed this as completed Dec 1, 2022
@klustria klustria added the 2.x Issues for 2.x version branch label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issues for 2.x version branch config enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

5 participants