Skip to content

Load config from optional resource #38

@mpe85

Description

@mpe85

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions