konfig icon indicating copy to clipboard operation
konfig copied to clipboard

Load config from optional resource

Open mpe85 opened this issue 5 years ago • 0 comments

It would be nice to have a function fromOptionalResource analogous to fromOptionalFile.

Currently I'm doing something like:

private fun ConfigurationProperties.Companion.fromOptionalResource(resourceName: String) =
  if (ClassLoader.getSystemResource(resourceName) != null) fromResource(resourceName)
  else EmptyConfiguration

private fun konfig(resourceName: String): Configuration = systemProperties() overriding
  EnvironmentVariables overriding
  ConfigurationProperties.fromOptionalResource(resourceName)

mpe85 avatar May 03 '19 14:05 mpe85