conferer-0.4.0.0: Configuration management library

Safe HaskellSafe
LanguageHaskell2010

Conferer.Source.Env

Contents

Synopsis

Env Source

This Source provides config values from env vars given a prefix that's used to avoid colliding with different system configuration

For example if you use the Prefix "awesomeapp" and get the Key "warp.port" this source will try to lookup the env var called AWESOMEAPP_WARP_PORT.

Usage

To use this source simply choose a prefix and add it using the addSource function like:

config & addSource (mkEnvSource "awesomeapp")

mkEnvSource :: Prefix -> SourceCreator Source #

SourceCreator for env Source that uses the real lookupEnv function

mkEnvSource' :: LookupEnvFunc -> Prefix -> SourceCreator Source #

SourceCreator for env Source that allows parameterizing the function used to lookup for testing

type Prefix = Text Source #

A text to namespace env vars

type LookupEnvFunc = String -> IO (Maybe String) Source #

Type alias for the function to lookup env vars

keyToEnvVar :: Prefix -> Key -> Text Source #

Get the env name from a prefix and a key by uppercasing and intercalating underscores

>>> keyToEnVar "awesomeapp" "warp.port"
"AWESOMEAPP_WARP_PORT"