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
Add support to configuration file per profile #11145
Add support to configuration file per profile #11145
Conversation
91c02cc
to
55d8c5c
Compare
@radcortez This might be of interest to you. I am wondering whether this has any impact on #9895 / smallrye/smallrye-config#363. |
Sort of. These are two different things, since Quarkus way to define profiles as you know is to list them all in the same file. For a multi-profile, multi-file approach we would need to look as many files as profiles defined, not just an additional file. |
Ok, thanks for your feedback. I just wanted to make sure that this not "diametrical" to what you have in mind for smalrye-config in context of #9895. |
BTW, I've already added support for profile aware smallrye/smallrye-config@96bada1 Anyway, we probably have to look into making Quarkus / SmallRye Config more consistent and off load most of the work to SmallRye Config. |
Nice! Maybe I should already add the same support for the MicroProfile files per profile in this PR. |
Ideally we should support both at the same time. It would look weird to support one type of file and not the other, even considering that most people will use the |
6170530
to
1ddae35
Compare
I included the treatment for MicroProfile files per profile as well. |
...untime/src/main/java/io/quarkus/runtime/configuration/ApplicationPropertiesConfigSource.java
Show resolved
Hide resolved
I really don't think I'm the one who should review this, but FWIW, this LGTM :-) (I actually prefer this style of config profiles over the |
@marcelorubim it seems you included an unrelated commit (awssdk update). |
a734475
to
ea9026c
Compare
Sorry! I did some mess while rebasing. Now it's fixed! Thanks for warning me! |
@@ -54,19 +56,25 @@ | |||
|
|||
public static final class InJar extends ApplicationPropertiesConfigSource { | |||
public InJar() { | |||
super(openStream(), 250); | |||
super(openStream(null), 260); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we keep the same ordinal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to follow up your sugestions.
I just keet the same pattern to add +10 for each one. But you're right. I would be better to not change the ordinal and only add +1.
} | ||
return is; | ||
} | ||
} | ||
|
||
public static final class InFileSystem extends ApplicationPropertiesConfigSource { | ||
public InFileSystem() { | ||
super(openStream(), 260); | ||
super(openStream(null), 280); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we keep the same ordinal?
@@ -123,10 +114,9 @@ public static void addSourceProviders(SmallRyeConfigBuilder builder, Collection< | |||
} | |||
|
|||
static class EnvConfigSource implements ConfigSource, Serializable { | |||
static final Pattern REP_PATTERN = Pattern.compile("[^a-zA-Z0-9_]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't seem necessary.
Since we are adding new sources with new ordinals, there is a chance (low, but it is there) that user custom sources (if in the range of the used ordinals), conflict with the new ones. Everything will work, but maybe some configuration resolution may yield different results. I would probably stick to use the same ordinal for the original sources and only increase the ordinal by +1 for the profile based properties. The chance will always be there, but it will make it even lower. |
ee09a08
to
06e9ef4
Compare
06e9ef4
to
553a447
Compare
553a447
to
06c2d2f
Compare
I'll take a look some time next week. There is a ton of work that has pilled up |
Question: What happens with this PR when a user add |
If the user adds
It will be ignored, as the file is only loaded for the |
So essentially a user can continue using the profile prefix inside the profile specific file?
I guess I wasn't clear. My question was what happens if |
Yes. I will be kind of redundant, but he can.
Quarkus will not load the And during the |
OK, thanks. I am +0 on this TBH (because we might be introducing too many ways to do the same thing), so I'll let others approve it. |
Is there anyone you'd suggest? Unfortunately this has stalled for over a month... |
I'd propose sending an email to the mailing list with a link to this to get more opinions |
This is awesome but I think the changes are also needed for yaml configs like on |
Multiple profiles are going to be available with #12789. |
This is very important for us too, it helps to keep the config clean. Is there any plan for when to merge this? |
hello, I think this is a good idea. here is a use case: https://groups.google.com/g/quarkus-dev/c/xCU6Yvw__ks |
There is also some work going to support additional locations: |
@radcortez didn't you implement it now? |
Yes. Sorry @marcelorubim. This is now provided by SmallRye Config as part of the MicroProfile Config 2.0 work (since this was added into the spec). Thank you for your effort. |
@radcortez Isn't Quarkus still on SmallRye Config 1.x? AFAICS, SmallRye Config 2.x is based on MicroProfile Config 2.0, right? |
Yes, but I back ported all the features that didn't have any API changes to the 1.x branch. |
Ah, I see. Do you remember in which PR you did that? I would like to assign this issue to a milestone and temove |
As described on issue #6810, this change adds the support to use a configuration file per-profile.
The user can have an
application.properties
with general configuration and one file for each profile, likeapplication-dev.profile
fordev
profile.Closes #6810