0

I am trying to automate some aspect of deploying a play2/sbt app to a restricted containerized environment, and have some limitation in place.

mainly what I am trying to achieve is to set database config for a specific named db connection only when the env variables are set.

Reading though the HOCON format documentation, I expected that the keys will be ignored if I don't set any of the substitution variables, but that wasn't the case, the app still pickups the somedb connection and tries to connect to it.

I suspect that maybe the db.somedb key is created anyway if there is a child key?

What can I do to have the behavior I am looking for.

please note that creating a separate config file and loading it is not an option for me

db {
  somedb.driver = ${?DB_DRIVER}
  somedb.url = ${?DB_URL}
  somedb.username = ${?DB_USERNAME}
  somedb.password = ${?DB_PASSWORD}
}
db.somedb.jndiName=${?DB_JNDI}

thank you

ezzarghili
  • 198
  • 14

1 Answers1

0

You could set a default value that is overriden by the ENV var like so:

somedb.driver = "changeme" somedb.driver = ${?DB_DRIVER}

Then you would have to check in your code if its overriden, e.g. with a pattern match.

Roberto
  • 41
  • 1
  • 5
  • Actually I don't want any default value, but I need the key to be totally ignored as if I didn't set it, which is not the case now – ezzarghili Mar 27 '17 at 15:19