Copyright | © 2015–2018 Stack Builders Inc. |
---|---|
License | MIT |
Maintainer | Stack Builders <[email protected]> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Configuration.Dotenv
Description
This module contains common functions to load and read dotenv files.
Synopsis
- load :: MonadIO m => Bool -> [(String, String)] -> m ()
- loadFile :: MonadIO m => Config -> m [(String, String)]
- loadSafeFile :: MonadIO m => ValidatorMap -> FilePath -> Config -> m [(String, String)]
- parseFile :: MonadIO m => FilePath -> m [(String, String)]
- onMissingFile :: MonadCatch m => m a -> m a -> m a
- data Config = Config {
- configPath :: [FilePath]
- configExamplePath :: [FilePath]
- configOverride :: Bool
- defaultConfig :: Config
- type ValidatorMap = Map Text (Text -> Bool)
- defaultValidatorMap :: ValidatorMap
Dotenv Load Functions
Arguments
:: MonadIO m | |
=> Bool | Override existing settings? |
-> [(String, String)] | List of values to be set in environment |
-> m () |
Loads the given list of options into the environment. Optionally override existing variables with values from Dotenv files.
Arguments
:: MonadIO m | |
=> Config | Dotenv configuration |
-> m [(String, String)] | Environment variables loaded |
loadFile
parses the environment variables defined in the dotenv example
file and checks if they are defined in the dotenv file or in the environment.
It also allows to override the environment variables defined in the environment
with the values defined in the dotenv file.
Arguments
:: MonadIO m | |
=> ValidatorMap | Map with custom validations |
-> FilePath | Filepath for schema file |
-> Config | Dotenv configuration |
-> m [(String, String)] | Environment variables loaded |
loadSafeFile
parses the .scheme.yml file and will perform the type checking
of the environment variables in the .env file.
Arguments
:: MonadIO m | |
=> FilePath | A file containing options to read |
-> m [(String, String)] | Variables contained in the file |
Parses the given dotenv file and returns values without adding them to the environment.
Arguments
:: MonadCatch m | |
=> m a | Action to perform that may fail because of missing file |
-> m a | Action to perform if file is indeed missing |
-> m a |
The helper allows to avoid exceptions in the case of missing files and perform some action instead.
Since: 0.3.1.0
Dotenv Types
Configuration Data Types with extra options for executing dotenv.
Constructors
Config | |
Fields
|
defaultConfig :: Config Source #
Default configuration. Use .env file without .env.example strict envs and without overriding.
type ValidatorMap = Map Text (Text -> Bool) Source #
Parameters:
- Key: Name of the format to check.
- Value: Function to check if some text meets the condition.
defaultValidatorMap :: ValidatorMap Source #
Default configuration for loadSafeFile
. It currently checks:
bool
, integer
, and text
.