lightbend / config

configuration library for JVM languages using HOCON files
https://lightbend.github.io/config/
6.17k stars 966 forks source link

include base(); "config://" url handler; #22

Open carrot-garden opened 12 years ago

carrot-garden commented 12 years ago

hello;

0) this is a feature request;

1) currently, include url()/file()/classpath() https://github.com/typesafehub/config/blob/master/HOCON.md#includes

are either relative or absolute, to the specific url: "otherwise, a file or other resource "adjacent to" the one being parsed"

2) I suggest to introduce a concept of a "base()" stanza: include base("common/server/instance/settings.conf") witch represents an idea: include form a root of "common configuration store", and is agnostic of url()/file()/classpath() distinctions;

3) "configuration store" would have to be a new concept for typesafe.config;

4) base() url handler would have to be provided to the typesafe.config library in some external way

5) another alternative would be to rely on new custom "config://" protocol handler explicitly, such as, in this stanza: include url("config://common/server/instance/settings.conf")

6) an example of custom url approach can be found here: https://github.com/barchart/barchart-config/tree/master/barchart-conf-base https://github.com/barchart/barchart-config/blob/master/barchart-conf-base/src/main/java/com/barchart/conf/impl/ConfigHandlerProvider.java

7) the benefit of "include base()" in typesafe.config would be to standardize the "configuration store" approach to configuration management;

thank you.

havocp commented 12 years ago

I'm not sure I understand all aspects of the suggestion, but you could add the base config directory to the classpath, right? or maybe there's a reason that a separate "config path" can be useful?

Also it should work to manually include one file from the base config directory, and then have that file include all the others relatively. Should only have to specify the full path to the first "bootstrap" file...

carrot-garden commented 12 years ago

Havoc, hello:

thanks for considering this; my typesafe.config use-case:

"master" https://github.com/carrot-garden/carrot-config-tester

"version" https://github.com/carrot-garden/carrot-config-tester/tree/version

thank you;

Andrei.

havocp commented 12 years ago

Thanks for the detailed use-case, I guess I would need to dig in here a bit. I think the hooks are there and you could use either the custom url protocol or a ConfigIncluder implementation to do this, but both are fairly cumbersome, so some kind of "just extend the search path" convenience feature could certainly make sense. Perhaps it could just be an option added to ConfigParseOptions (say setSearchPath), and also a system property supported in ConfigFactory.load (similar to -Dconfig.file= etc. we could have config.path). Something along those lines, not sure.

carrot-garden commented 12 years ago

cool; let it cook then :-)

havocp commented 9 years ago

Also relevant is #202, right now includes are not in fact relative to the including file if you specify url()/file()/classpath().

briantopping commented 8 years ago

@carrot-garden: I assume you solved this by now, four years later ;) May I ask what you did?

ajayvkm commented 3 years ago

Hey @havocp (Havoc) and @carrot-garden, Can we use this Typesafe Library (Lightbend) in a distributed environment? I have a use case to read configuration from GIT similar to Spring Boot Cloud Configuration. Wanted to load configuration properties from Git and a particular Git Branch/Tags. Please let me know if it is possible with this library. Thanks a lot!!

Anatoliy4041 commented 2 years ago

Hi @havocp and @akka-team,

Can we use this Typesafe Library (Lightbend) in a distributed environment? I have a use case to read configuration from GIT similar to Spring Boot Cloud Configuration. Wanted to load configuration properties from Git and a particular Git Branch/Tags. Please let me know if it is possible with this library. Thanks a lot!!

Is there any update on @ajayvkm comment? I would be very useful feature