https://kotlinlang.org logo
Title
h

Horv

06/24/2019, 7:12 PM
Is there any way to change a subset of variables in config depending on environment? What I'd like is something like
application.conf
    variable1: value1
    variable2: value2

application-dev.conf
    variable3: value3
And be able to run the application with both
application.conf
and
application-dev.conf
applied. Or possibly 1 config file but evaluate different configs depending on environment variables. When reading up on
HOCON
I couldn't find it it supports any kind of ternary operator or so.
b

Ben

06/24/2019, 8:49 PM
You could just pass in another config in the command line https://ktor.io/servers/configuration.html#command-line
o

obobo

06/24/2019, 8:57 PM
You can load Hocon by hand, too: if you pass in
-Dconfig.file=application.conf
it will load in
reference.conf
and then merge
application.conf
onto it And then you can instance your server like
val hoconConfig = ConfigFactory.load().resolve()
server = embeddedServer(YourEngine, applicationEngineEnvironment {
config = HoconApplicationConfig(hoconConfig)
}).start()