I am using Scaldi with Play and Slick in my application.
I need to bind a DatabaseConfig dependency to different configurations depending on some condition.
- Mode = Dev => Oracle DB
- Mode = UAT => Another Oracle DB ...
- Mode = Test => Local H2 DB
- No Mode specified => same as Mode = Test
How do I handle the last part? I tried to do the following but it does not work.
val inDevMode = SysPropCondition(name = "mode", value = Some("dev"))
val inTestMode = SysPropCondition(name = "mode", value = Some("test")) or SysPropCondition(name = "mode", value = None)
bind [DatabaseConfig[JdbcProfile]] when (inDevMode) to new DbConfigHelper().getDecryptedConfig("gem2g") destroyWith (_.db.close)
bind [DatabaseConfig[JdbcProfile]] when (inTestMode) to DatabaseConfig.forConfig[JdbcProfile]("h2") destroyWith (_.db.close)
val inTestMode = SysPropCondition(name=MODE, value=Some("test")) or SysPropCondition(name=MODE, value=None) or Condition(System.getProperty(MODE) == null)