lightbend / config

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

how to load the config with substitution details #794

Open srikanth-exabeam opened 1 year ago

srikanth-exabeam commented 1 year ago

we have the config below format

LocationDataTemplate = {
    sample-data-template = {
        City = Mumbai
        Country = India
    }
}

HotelDetails = [
{
    Name = "The Taj Mahal Palace"
    Address = "Colaba"
},

    ${LocationDataTemplate.sample-data-template}{
        Name = "Four Seasons Hotel"
        Address = "Worli"
    }
]

In HotelDetails we are using substitution as ${LocationDataTemplate.sample-data-template}. While loading this config data of 'HotelDetails' we want to load with substitution details intact as we want to maintain reference of substitution.

We tried multiple scenarios but did not got the way to load details with substitutions. Please share sample code for this scenario.

ekrich commented 1 year ago

The documentation is pretty good but it doesn't seem you can do what you are asking - https://github.com/lightbend/config#uses-of-substitutions

srikanth-exabeam commented 1 year ago

The documentation is pretty good but it doesn't seem you can do what you are asking - https://github.com/lightbend/config#uses-of-substitutions

@ekrich the link you shared is for uses of substitutions, but we need raw details of substitutions. ConfigConcatenation.java has the 'pieces' property to share substitution and config details separately but we can't use 'ConfigConcatenation' class since it has default scoped.

havocp commented 1 year ago

maybe ConfigResolver can help?

Otherwise the unfinished ConfigDocument api would be the needed thing to use the library as a parser.