gs-config/src/main/scala/gs/config/v0/source/EnvironmentConfigSource.scala
Pat Garrity 3907d33de2
All checks were successful
/ Build and Test Library Snapshot (pull_request) Successful in 1m26s
(patch) Initial implementation of the configuration library.
2024-05-01 21:49:45 -05:00

20 lines
540 B
Scala

package gs.config.v0.source
import cats.effect.Sync
import gs.config.v0.ConfigKey
/** Environment variable implementation of [[ConfigSource]]. Pulls all values
* from the system environment that was passed to this process.
*/
final class EnvironmentConfigSource[F[_]: Sync] extends ConfigSource[F]:
/** @inheritDocs
*/
override def getValue(
key: ConfigKey[?]
): F[Option[String]] =
Sync[F].delay(sys.env.get(key.name.toEnvironmentVariable()))
/** @inheritDocs
*/
override val name: String = "environment"