Open
Description
I'm always doing the same thing. Make this easier out-of-the-box:
def sources: ConfigSources[IO] =
// Highest pri
ConfigSource.environment[IO].expandInlineProperties("APP_PROPS").mapKeyQueries(acceptExternalKeyFormat) >
ConfigSource.propFileOnClasspath[IO]("app.properties", optional = true) >
ConfigSource.system[IO]
// Lowest pri
private def acceptExternalKeyFormat(k: ConfigKey): List[ConfigKey] =
k :: k.map(_.toUpperCase.replace('.', '_')) :: Nil
def load: IO[Option[AppConfig]] =
config
.withReport
.run(sources)
.map { result =>
result.toEither match {
case Right((config, report)) =>
if (config.showUnusedConfig)
logger.info("Config report\n" + report.full)
else
logger.info("Config report\n" + report.sources + "\n\n" + report.used)
Some(config)
case Left(err) =>
logger.error("Invalid config:\n" + err)
None
}
}
Metadata
Metadata
Assignees
Labels
No labels