We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For example:
val port = ConfigDef.getOrUse[Port]("server.port", port"8085") def configSources[F[_]: Applicative]: ConfigSources[F] = { // Allow property names like `foo.bar` to map to environment variables like `FOO_BAR` // Taken from https://github.com/japgolly/clear-config/issues/132 def propertyToEnv(k: ConfigKey): List[ConfigKey] = k :: k.map(_.toUpperCase.replace('.', '_')) :: Nil ConfigSource.environment[F].mapKeyQueries(propertyToEnv) > ConfigSource.propFile[F]("deploy.properties", optional = true) ConfigSource.system[F] } def readConfig[F[_]: MonadThrow](log: Logger[F]): F[MainConfig] = config.withReport .run(configSources[F]) .flatMap(_.toEither.leftMap(e => new Exception(e) with NoStackTrace {}).liftTo[F]) .flatMap { case (cfg, report) => // Don't bother reporting unused environment variables, or "system" settings val reportMessage = report .mapUnused(_.withoutSources(ConfigSourceName.environment, ConfigSourceName.system)) .full log .info(reportMessage) .as(cfg) }
Results in a config report like this:
Used keys (5): +-----------------+------+-----------------------------------------------------------------+---------+ | Key | Env | /Users/gavin/blahblah/blahblahblahblahblah/local-dev.properties | Default | +-----------------+------+-----------------------------------------------------------------+---------+ | SERVER_PORT | 8089 | | | | server.port | | | 8085 | +-----------------+------+-----------------------------------------------------------------+---------+
The text was updated successfully, but these errors were encountered:
No branches or pull requests
For example:
Results in a config report like this:
The text was updated successfully, but these errors were encountered: