ConfigSource

interface ConfigSource(source)

A place config values are read from, such as environment variables or a file. For each field, ConfigLoader builds the key in keyFormat, then in each of fallbackKeyFormats, and asks get for each until one returns a value, before moving on to the next source.

class FlagSource(private val flags: Map<String, String>) : ConfigSource {
override val keyFormat = KeyFormat.DOT_NOTATION
override fun get(key: String): String? = flags[key]
}

Inheritors

Properties

Link copied to clipboard

Further formats tried in order when the key in keyFormat has no value. None by default.

Link copied to clipboard
abstract val keyFormat: KeyFormat

The key format tried first, e.g. KeyFormat.SCREAMING_SNAKE for environment variables.

Link copied to clipboard
open val name: String

A short label for reports such as ConfigLoader.explain, e.g. TomlSource.

Functions

Link copied to clipboard
open fun children(key: String): Map<String, String>?

Entries nested under key as key.child, keyed by child, or null if there are none. Sources that flatten tables and mappings (TOML, YAML, properties) use this to fill Map fields.

Link copied to clipboard
abstract fun get(key: String): String?

The raw text for key, or null if this source does not have it.