On Fri, Jun 24, 2022 at 4:31 AM Stephane Epardaud
<
stephane...@gmail.com> wrote:
> On Fri, 24 Jun 2022 at 10:29, Yoann Rodiere <
yo...@hibernate.org> wrote:
>>
>> *Solution 1*: I initially suggested a special syntax to specify a single property for multiple profiles in a single line.
>>
>> ```
>> %[dev,test].quarkus.hibernate-orm.database.generation=drop-and-create
>> %[dev,test].quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus_test
>> %[dev,test].quarkus.datasource.username=testuser
>> %[dev,test].quarkus.datasource.password=testpassword
>> ```
>
> Sounds useful even for use-cases outside of this particular example. I don't see why we wouldn't support this.
A qualified +1 from me (see below).
> Honestly, this feels like it should be a negative profile, to support all "non-X" profiles.
>
> %!prod.quarkus.something=bar
> %!dev.quarkus.something=bar
I agree, but my bikeshed paint color would be:
%~prod.quarkus.something=bar
On Mon, Jun 27, 2022 at 6:31 AM 'Roberto Cortez' via Quarkus
Development mailing list <
quark...@googlegroups.com> wrote:
> The parent.profile was added for this exact use case (and a few more).
>
> For me is not a big deal to add it when I need it, but I can understand that it may distract you from your original goal when doing demos.
>
> I’m not a big fan of introducing new syntax into the configuration names. We already use [ ] to represent indexed values for Collections. Yes it would be possible to support them for profiles, due to the leading %, but still, it doesn’t feel right to me to use very similar syntax for two different scenarios:
>
> # already supported
> my.property[0]=value
> my.property.object[0].name=value
>
> # with the proposal
> %[dev,test].my.property[0]=value
> %[dev,test].my.property.object[0].name=value
That's fair, but to me it's no different than Java using {} for both
blocks and arrays, or C using `&` as both a unary address-of operator
and a binary bitwise-AND operator. The usage is clear from context.
> We are now specifying multiple values for a collection (profiles). So I guess that naturally, people will expect to be able to do things like these:
>
> my.property.object[0].name=Bob
> my.property.object[1].name=Alice
> # multiple indexes separated by comma
> my.property.object[0,1].surname=Doe
I don't envision that TBH. As I said it's pretty clear from context;
and if `[]` is really super problematic we could always use a
different bracketing character like:
%{dev,test}.my.property[0]=Foo
> Now comes the fun part of environment variables:
>
> _DEV_TEST_MY_PROPERTY
Is there a good reason to support profiles with environment variables
at all? It seems like you might use them to *select* the profile, but
it seems to me that they're very close to the "metal" of the
deployment environment to be provisionally qualifying properties with
profiles at that stage.
> With a single profile per property, we just check the first segment for a valid active profile. With multiple ones we need to check the entire key:
>
> %[dev,test].my.property=
> %[dev,test,my].property=
> %[dev,test,my,property]=
I guess if it were *necessary* to allow this with env vars, it would be:
__DEV_TEST__MY_PROPERTY=
__DEV_TEST_MY__PROPERTY=
__DEV_TEST_MY_PROPERTY_=
I wouldn't consider that a victory for usability, but it is at least
unambiguous and consistent with how we handle quoted properties.
> Then we have the profile aware files (application-dev.properties, application-test.properties):
>
> Right now you also have to duplicate the keys (if you don’t use the parent profile). The proposed solution is only solving the issue for properties in a single file, but what we are observing is people using more and more profile-aware files (because of large configuration files, and they are used to doing it with Spring). So, how to handle profile-aware files?
I would say, *don't*. It's a convenience for sure, for those who are
accustomed to it. But solving a problem in one area does not mean it
must be solved in all areas. Particularly, this feature is a good way
to let us be more opinionated: "you *can* do multiple files but it's
often better to do one".
> Remember that every new syntax MUST work with every available configuration source and format.
Better to say, there must be a syntax which allows each new feature to
be expressed in every available configuration source and format. Can
we express these syntaxes neatly in YAML, and secondary languages like
TOML or JSON?
> I’m always happy to add new stuff. Quite frankly, we already have so many configuration options and alternatives that I want to be extremely careful when adding more.
This is a fair point. Configuration has evolved quite a lot since the
initial release and it's getting a bit difficult to manage the ever
increasing complexity, so this is a factor that has to be considered.
--
- DML • he/him